#ifndef NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_
#define NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_
#include <string>
#include <vector>
#include "net/cookies/cookie_store.h"
namespace base {
class MessageLoop;
class Thread;
}
namespace net {
class CookieCallback {
public:
bool did_run() { return did_run_; }
protected:
explicit CookieCallback(base::Thread* run_in_thread);
CookieCallback();
void CallbackEpilogue();
private:
bool did_run_;
base::Thread* run_in_thread_;
base::MessageLoop* run_in_loop_;
base::MessageLoop* parent_loop_;
base::MessageLoop* loop_to_quit_;
};
template <typename T>
class ResultSavingCookieCallback : public CookieCallback {
public:
ResultSavingCookieCallback() {
}
explicit ResultSavingCookieCallback(base::Thread* run_in_thread)
: CookieCallback(run_in_thread) {
}
void Run(T result) {
result_ = result;
CallbackEpilogue();
}
const T& result() { return result_; }
private:
T result_;
};
class StringResultCookieCallback : public CookieCallback {
public:
StringResultCookieCallback();
explicit StringResultCookieCallback(base::Thread* run_in_thread);
void Run(const std::string& result) {
result_ = result;
CallbackEpilogue();
}
const std::string& result() { return result_; }
private:
std::string result_;
};
class NoResultCookieCallback : public CookieCallback {
public:
NoResultCookieCallback();
explicit NoResultCookieCallback(base::Thread* run_in_thread);
void Run() {
CallbackEpilogue();
}
};
}
#endif