| Index: net/cookies/cookie_store_unittest.h
|
| diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h
|
| index 9a0fc0cdbe8c6b9259c687a44e407d769ecd3e48..141cce564c864bac0e0fac24c53ccbb2ea1a9fb7 100644
|
| --- a/net/cookies/cookie_store_unittest.h
|
| +++ b/net/cookies/cookie_store_unittest.h
|
| @@ -1397,179 +1397,6 @@ REGISTER_TYPED_TEST_CASE_P(CookieStoreTest,
|
| DeleteCanonicalCookieAsync,
|
| DeleteSessionCookie);
|
|
|
| -template<class CookieStoreTestTraits>
|
| -class MultiThreadedCookieStoreTest :
|
| - public CookieStoreTest<CookieStoreTestTraits> {
|
| - public:
|
| - MultiThreadedCookieStoreTest() : other_thread_("CMTthread") {}
|
| -
|
| - // Helper methods for calling the asynchronous CookieStore methods
|
| - // from a different thread.
|
| -
|
| - void GetCookiesTask(CookieStore* cs,
|
| - const GURL& url,
|
| - StringResultCookieCallback* callback) {
|
| - CookieOptions options;
|
| - if (!CookieStoreTestTraits::supports_http_only)
|
| - options.set_include_httponly();
|
| - cs->GetCookiesWithOptionsAsync(
|
| - url, options,
|
| - base::Bind(&StringResultCookieCallback::Run,
|
| - base::Unretained(callback)));
|
| - }
|
| -
|
| - void GetCookiesWithOptionsTask(CookieStore* cs,
|
| - const GURL& url,
|
| - const CookieOptions& options,
|
| - StringResultCookieCallback* callback) {
|
| - cs->GetCookiesWithOptionsAsync(
|
| - url, options,
|
| - base::Bind(&StringResultCookieCallback::Run,
|
| - base::Unretained(callback)));
|
| - }
|
| -
|
| - void SetCookieWithOptionsTask(CookieStore* cs,
|
| - const GURL& url,
|
| - const std::string& cookie_line,
|
| - const CookieOptions& options,
|
| - ResultSavingCookieCallback<bool>* callback) {
|
| - cs->SetCookieWithOptionsAsync(
|
| - url, cookie_line, options,
|
| - base::Bind(
|
| - &ResultSavingCookieCallback<bool>::Run,
|
| - base::Unretained(callback)));
|
| - }
|
| -
|
| - void DeleteCookieTask(CookieStore* cs,
|
| - const GURL& url,
|
| - const std::string& cookie_name,
|
| - NoResultCookieCallback* callback) {
|
| - cs->DeleteCookieAsync(
|
| - url, cookie_name,
|
| - base::Bind(&NoResultCookieCallback::Run, base::Unretained(callback)));
|
| - }
|
| -
|
| - void DeleteSessionCookiesTask(CookieStore* cs,
|
| - ResultSavingCookieCallback<int>* callback) {
|
| - cs->DeleteSessionCookiesAsync(
|
| - base::Bind(
|
| - &ResultSavingCookieCallback<int>::Run,
|
| - base::Unretained(callback)));
|
| - }
|
| -
|
| - protected:
|
| - void RunOnOtherThread(const base::Closure& task) {
|
| - other_thread_.Start();
|
| - other_thread_.task_runner()->PostTask(FROM_HERE, task);
|
| - other_thread_.Stop();
|
| - }
|
| -
|
| - Thread other_thread_;
|
| -};
|
| -
|
| -TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest);
|
| -
|
| -// TODO(ycxiao): Eventually, we will need to create a separate thread, create
|
| -// the cookie store on that thread (or at least its store, i.e., the DB
|
| -// thread).
|
| -TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookies) {
|
| - scoped_refptr<CookieStore> cs(this->GetCookieStore());
|
| - EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B"));
|
| - this->MatchCookieLines(
|
| - "A=B", this->GetCookies(cs.get(), this->http_www_google_.url()));
|
| - StringResultCookieCallback callback(&this->other_thread_);
|
| - base::Closure task = base::Bind(
|
| - &MultiThreadedCookieStoreTest<TypeParam>::GetCookiesTask,
|
| - base::Unretained(this), cs, this->http_www_google_.url(), &callback);
|
| - this->RunOnOtherThread(task);
|
| - callback.WaitUntilDone();
|
| - EXPECT_EQ("A=B", callback.result());
|
| -}
|
| -
|
| -TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckGetCookiesWithOptions) {
|
| - scoped_refptr<CookieStore> cs(this->GetCookieStore());
|
| - CookieOptions options;
|
| - if (!TypeParam::supports_http_only)
|
| - options.set_include_httponly();
|
| - EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B"));
|
| - this->MatchCookieLines(
|
| - "A=B", this->GetCookiesWithOptions(cs.get(), this->http_www_google_.url(),
|
| - options));
|
| - StringResultCookieCallback callback(&this->other_thread_);
|
| - base::Closure task = base::Bind(
|
| - &MultiThreadedCookieStoreTest<TypeParam>::GetCookiesWithOptionsTask,
|
| - base::Unretained(this), cs, this->http_www_google_.url(), options,
|
| - &callback);
|
| - this->RunOnOtherThread(task);
|
| - callback.WaitUntilDone();
|
| - EXPECT_EQ("A=B", callback.result());
|
| -}
|
| -
|
| -TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckSetCookieWithOptions) {
|
| - scoped_refptr<CookieStore> cs(this->GetCookieStore());
|
| - CookieOptions options;
|
| - if (!TypeParam::supports_http_only)
|
| - options.set_include_httponly();
|
| - EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(),
|
| - "A=B", options));
|
| - ResultSavingCookieCallback<bool> callback(&this->other_thread_);
|
| - base::Closure task = base::Bind(
|
| - &MultiThreadedCookieStoreTest<TypeParam>::SetCookieWithOptionsTask,
|
| - base::Unretained(this), cs, this->http_www_google_.url(), "A=B", options,
|
| - &callback);
|
| - this->RunOnOtherThread(task);
|
| - callback.WaitUntilDone();
|
| - EXPECT_TRUE(callback.result());
|
| -}
|
| -
|
| -TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteCookie) {
|
| - scoped_refptr<CookieStore> cs(this->GetCookieStore());
|
| - CookieOptions options;
|
| - if (!TypeParam::supports_http_only)
|
| - options.set_include_httponly();
|
| - EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(),
|
| - "A=B", options));
|
| - this->DeleteCookie(cs.get(), this->http_www_google_.url(), "A");
|
| - EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(),
|
| - "A=B", options));
|
| - NoResultCookieCallback callback(&this->other_thread_);
|
| - base::Closure task = base::Bind(
|
| - &MultiThreadedCookieStoreTest<TypeParam>::DeleteCookieTask,
|
| - base::Unretained(this), cs, this->http_www_google_.url(), "A", &callback);
|
| - this->RunOnOtherThread(task);
|
| - callback.WaitUntilDone();
|
| -}
|
| -
|
| -TYPED_TEST_P(MultiThreadedCookieStoreTest, ThreadCheckDeleteSessionCookies) {
|
| - scoped_refptr<CookieStore> cs(this->GetCookieStore());
|
| - CookieOptions options;
|
| - if (!TypeParam::supports_http_only)
|
| - options.set_include_httponly();
|
| - EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(),
|
| - "A=B", options));
|
| - EXPECT_TRUE(this->SetCookieWithOptions(
|
| - cs.get(), this->http_www_google_.url(),
|
| - "B=C; expires=Mon, 18-Apr-22 22:50:13 GMT", options));
|
| - EXPECT_EQ(1, this->DeleteSessionCookies(cs.get()));
|
| - EXPECT_EQ(0, this->DeleteSessionCookies(cs.get()));
|
| - EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(),
|
| - "A=B", options));
|
| - ResultSavingCookieCallback<int> callback(&this->other_thread_);
|
| - base::Closure task = base::Bind(
|
| - &MultiThreadedCookieStoreTest<TypeParam>::DeleteSessionCookiesTask,
|
| - base::Unretained(this), cs, &callback);
|
| - this->RunOnOtherThread(task);
|
| - callback.WaitUntilDone();
|
| - EXPECT_EQ(1, callback.result());
|
| -}
|
| -
|
| -REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest,
|
| - ThreadCheckGetCookies,
|
| - ThreadCheckGetCookiesWithOptions,
|
| - ThreadCheckSetCookieWithOptions,
|
| - ThreadCheckDeleteCookie,
|
| - ThreadCheckDeleteSessionCookies);
|
| -
|
| } // namespace net
|
|
|
| #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_
|
|
|