Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1007)

Side by Side Diff: net/cookies/cookie_store_test_callbacks.cc

Issue 1634803004: Convert CookieMonster tests to use base::RunLoop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_store_test_callbacks.h ('k') | net/cookies/cookie_store_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cookies/cookie_store_test_callbacks.h" 5 #include "net/cookies/cookie_store_test_callbacks.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 CookieCallback::CookieCallback(base::Thread* run_in_thread) 15 CookieCallback::CookieCallback(base::Thread* run_in_thread)
16 : did_run_(false), 16 : run_in_thread_(run_in_thread), run_in_loop_(NULL) {}
17 run_in_thread_(run_in_thread),
18 run_in_loop_(NULL),
19 parent_loop_(base::MessageLoop::current()),
20 loop_to_quit_(base::MessageLoop::current()) {}
21 17
22 CookieCallback::CookieCallback() 18 CookieCallback::CookieCallback()
23 : did_run_(false), 19 : run_in_thread_(NULL), run_in_loop_(base::MessageLoop::current()) {}
24 run_in_thread_(NULL), 20
25 run_in_loop_(base::MessageLoop::current()), 21 CookieCallback::~CookieCallback() {}
26 parent_loop_(NULL),
27 loop_to_quit_(base::MessageLoop::current()) {}
28 22
29 void CookieCallback::CallbackEpilogue() { 23 void CookieCallback::CallbackEpilogue() {
30 base::MessageLoop* expected_loop = NULL; 24 base::MessageLoop* expected_loop = NULL;
31 if (run_in_thread_) { 25 if (run_in_thread_) {
32 DCHECK(!run_in_loop_); 26 DCHECK(!run_in_loop_);
33 expected_loop = run_in_thread_->message_loop(); 27 expected_loop = run_in_thread_->message_loop();
34 } else if (run_in_loop_) { 28 } else if (run_in_loop_) {
35 expected_loop = run_in_loop_; 29 expected_loop = run_in_loop_;
36 } 30 }
37 ASSERT_TRUE(expected_loop != NULL); 31 ASSERT_TRUE(expected_loop != NULL);
38 32
39 did_run_ = true;
40 EXPECT_EQ(expected_loop, base::MessageLoop::current()); 33 EXPECT_EQ(expected_loop, base::MessageLoop::current());
41 loop_to_quit_->task_runner()->PostTask( 34 loop_to_quit_.Quit();
42 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 35 }
36
37 void CookieCallback::WaitUntilDone() {
38 loop_to_quit_.Run();
43 } 39 }
44 40
45 StringResultCookieCallback::StringResultCookieCallback() {} 41 StringResultCookieCallback::StringResultCookieCallback() {}
46 StringResultCookieCallback::StringResultCookieCallback( 42 StringResultCookieCallback::StringResultCookieCallback(
47 base::Thread* run_in_thread) 43 base::Thread* run_in_thread)
48 : CookieCallback(run_in_thread) {} 44 : CookieCallback(run_in_thread) {}
49 45
50 NoResultCookieCallback::NoResultCookieCallback() {} 46 NoResultCookieCallback::NoResultCookieCallback() {}
51 NoResultCookieCallback::NoResultCookieCallback(base::Thread* run_in_thread) 47 NoResultCookieCallback::NoResultCookieCallback(base::Thread* run_in_thread)
52 : CookieCallback(run_in_thread) {} 48 : CookieCallback(run_in_thread) {}
53 49
54 GetCookieListCallback::GetCookieListCallback() {} 50 GetCookieListCallback::GetCookieListCallback() {}
55 GetCookieListCallback::GetCookieListCallback(base::Thread* run_in_thread) 51 GetCookieListCallback::GetCookieListCallback(base::Thread* run_in_thread)
56 : CookieCallback(run_in_thread) {} 52 : CookieCallback(run_in_thread) {}
57 53
58 GetCookieListCallback::~GetCookieListCallback() {} 54 GetCookieListCallback::~GetCookieListCallback() {}
59 55
60 void GetCookieListCallback::Run(const CookieList& cookies) { 56 void GetCookieListCallback::Run(const CookieList& cookies) {
61 cookies_ = cookies; 57 cookies_ = cookies;
62 CallbackEpilogue(); 58 CallbackEpilogue();
63 } 59 }
64 60
65 } // namespace net 61 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_store_test_callbacks.h ('k') | net/cookies/cookie_store_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698