OLD | NEW |
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 #ifndef NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_ | 5 #ifndef NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_ |
6 #define NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_ | 6 #define NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "net/cookies/cookie_store.h" | 11 #include "net/cookies/cookie_store.h" |
12 | 12 |
| 13 namespace base { |
13 class MessageLoop; | 14 class MessageLoop; |
14 | |
15 namespace base { | |
16 class Thread; | 15 class Thread; |
17 } | 16 } |
18 | 17 |
19 namespace net { | 18 namespace net { |
20 | 19 |
21 // Defines common behaviour for the callbacks from GetCookies, SetCookies, etc. | 20 // Defines common behaviour for the callbacks from GetCookies, SetCookies, etc. |
22 // Asserts that the current thread is the expected invocation thread, sends a | 21 // Asserts that the current thread is the expected invocation thread, sends a |
23 // quit to the thread in which it was constructed. | 22 // quit to the thread in which it was constructed. |
24 class CookieCallback { | 23 class CookieCallback { |
25 public: | 24 public: |
26 // Indicates whether the callback has been called. | 25 // Indicates whether the callback has been called. |
27 bool did_run() { return did_run_; } | 26 bool did_run() { return did_run_; } |
28 | 27 |
29 protected: | 28 protected: |
30 // Constructs a callback that expects to be called in the given thread and | 29 // Constructs a callback that expects to be called in the given thread and |
31 // will, upon execution, send a QUIT to the constructing thread. | 30 // will, upon execution, send a QUIT to the constructing thread. |
32 explicit CookieCallback(base::Thread* run_in_thread); | 31 explicit CookieCallback(base::Thread* run_in_thread); |
33 | 32 |
34 // Constructs a callback that expects to be called in current thread and will | 33 // Constructs a callback that expects to be called in current thread and will |
35 // send a QUIT to the constructing thread. | 34 // send a QUIT to the constructing thread. |
36 CookieCallback(); | 35 CookieCallback(); |
37 | 36 |
38 // Tests whether the current thread was the caller's thread. | 37 // Tests whether the current thread was the caller's thread. |
39 // Sends a QUIT to the constructing thread. | 38 // Sends a QUIT to the constructing thread. |
40 void CallbackEpilogue(); | 39 void CallbackEpilogue(); |
41 | 40 |
42 private: | 41 private: |
43 bool did_run_; | 42 bool did_run_; |
44 base::Thread* run_in_thread_; | 43 base::Thread* run_in_thread_; |
45 MessageLoop* run_in_loop_; | 44 base::MessageLoop* run_in_loop_; |
46 MessageLoop* parent_loop_; | 45 base::MessageLoop* parent_loop_; |
47 MessageLoop* loop_to_quit_; | 46 base::MessageLoop* loop_to_quit_; |
48 }; | 47 }; |
49 | 48 |
50 // Callback implementations for the asynchronous CookieStore methods. | 49 // Callback implementations for the asynchronous CookieStore methods. |
51 | 50 |
52 class SetCookieCallback : public CookieCallback { | 51 class SetCookieCallback : public CookieCallback { |
53 public: | 52 public: |
54 SetCookieCallback(); | 53 SetCookieCallback(); |
55 explicit SetCookieCallback(base::Thread* run_in_thread); | 54 explicit SetCookieCallback(base::Thread* run_in_thread); |
56 | 55 |
57 void Run(bool result) { | 56 void Run(bool result) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 explicit DeleteCookieCallback(base::Thread* run_in_thread); | 102 explicit DeleteCookieCallback(base::Thread* run_in_thread); |
104 | 103 |
105 void Run() { | 104 void Run() { |
106 CallbackEpilogue(); | 105 CallbackEpilogue(); |
107 } | 106 } |
108 }; | 107 }; |
109 | 108 |
110 } // namespace net | 109 } // namespace net |
111 | 110 |
112 #endif // NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_ | 111 #endif // NET_COOKIES_COOKIE_STORE_TEST_CALLBACKS_H_ |
OLD | NEW |