OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // base class method to return default value. | 57 // base class method to return default value. |
58 return user_agent_.empty() ? | 58 return user_agent_.empty() ? |
59 URLRequestContext::GetUserAgent(url) : user_agent_; | 59 URLRequestContext::GetUserAgent(url) : user_agent_; |
60 } | 60 } |
61 | 61 |
62 virtual bool AllowSendingCookies(const URLRequest* request) const { | 62 virtual bool AllowSendingCookies(const URLRequest* request) const { |
63 return false; | 63 return false; |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
| 67 // The destructor MUST be called on the IO thread. |
67 ~RequestContext(); | 68 ~RequestContext(); |
68 | 69 |
69 std::string user_agent_; | 70 std::string user_agent_; |
70 URLRequestContext* baseline_context_; | 71 URLRequestContext* baseline_context_; |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(RequestContext); | 73 DISALLOW_COPY_AND_ASSIGN(RequestContext); |
73 }; | 74 }; |
74 | 75 |
75 // Lazy-getter for RequestContext objects. | 76 // Lazy-getter for RequestContext objects. |
76 class RequestContextGetter : public URLRequestContextGetter { | 77 class RequestContextGetter : public URLRequestContextGetter { |
77 public: | 78 public: |
78 explicit RequestContextGetter( | 79 explicit RequestContextGetter( |
79 URLRequestContextGetter* baseline_context_getter); | 80 URLRequestContextGetter* baseline_context_getter); |
80 | 81 |
81 void set_user_agent(const std::string& ua) { user_agent_ = ua; } | 82 void set_user_agent(const std::string& ua) { user_agent_ = ua; } |
82 bool is_user_agent_set() const { return !user_agent_.empty(); } | 83 bool is_user_agent_set() const { return !user_agent_.empty(); } |
83 | 84 |
84 // URLRequestContextGetter implementation. | 85 // URLRequestContextGetter implementation. |
85 virtual URLRequestContext* GetURLRequestContext(); | 86 virtual URLRequestContext* GetURLRequestContext(); |
| 87 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy(); |
86 | 88 |
87 private: | 89 private: |
88 ~RequestContextGetter() {} | 90 ~RequestContextGetter() {} |
89 | 91 |
90 // User agent to apply to the URLRequestContext. | 92 // User agent to apply to the URLRequestContext. |
91 std::string user_agent_; | 93 std::string user_agent_; |
92 | 94 |
93 scoped_refptr<URLRequestContextGetter> baseline_context_getter_; | 95 scoped_refptr<URLRequestContextGetter> baseline_context_getter_; |
94 | 96 |
95 // Lazily initialized by GetURLRequestContext(). | 97 // Lazily initialized by GetURLRequestContext(). |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // This request context is built on top of the baseline context and shares | 201 // This request context is built on top of the baseline context and shares |
200 // common components. | 202 // common components. |
201 HttpBridge::RequestContextGetter* GetRequestContextGetter(); | 203 HttpBridge::RequestContextGetter* GetRequestContextGetter(); |
202 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; | 204 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; |
203 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); | 205 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); |
204 }; | 206 }; |
205 | 207 |
206 } // namespace browser_sync | 208 } // namespace browser_sync |
207 | 209 |
208 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 210 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
| 211 |
OLD | NEW |