OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 virtual const std::string& GetUserAgent(const GURL& url) const { | 55 virtual const std::string& GetUserAgent(const GURL& url) const { |
56 // If the user agent is set explicitly return that, otherwise call the | 56 // If the user agent is set explicitly return that, otherwise call the |
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 net::URLRequestContext::GetUserAgent(url) : user_agent_; | 59 net::URLRequestContext::GetUserAgent(url) : user_agent_; |
60 } | 60 } |
61 | 61 |
62 private: | 62 private: |
63 // The destructor MUST be called on the IO thread. | 63 // The destructor MUST be called on the IO thread. |
64 ~RequestContext(); | 64 virtual ~RequestContext(); |
65 | 65 |
66 std::string user_agent_; | 66 std::string user_agent_; |
67 net::URLRequestContext* baseline_context_; | 67 net::URLRequestContext* baseline_context_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(RequestContext); | 69 DISALLOW_COPY_AND_ASSIGN(RequestContext); |
70 }; | 70 }; |
71 | 71 |
72 // Lazy-getter for RequestContext objects. | 72 // Lazy-getter for RequestContext objects. |
73 class RequestContextGetter : public net::URLRequestContextGetter { | 73 class RequestContextGetter : public net::URLRequestContextGetter { |
74 public: | 74 public: |
75 explicit RequestContextGetter( | 75 explicit RequestContextGetter( |
76 net::URLRequestContextGetter* baseline_context_getter); | 76 net::URLRequestContextGetter* baseline_context_getter); |
77 | 77 |
78 void set_user_agent(const std::string& ua) { user_agent_ = ua; } | 78 void set_user_agent(const std::string& ua) { user_agent_ = ua; } |
79 bool is_user_agent_set() const { return !user_agent_.empty(); } | 79 bool is_user_agent_set() const { return !user_agent_.empty(); } |
80 | 80 |
81 // net::URLRequestContextGetter implementation. | 81 // net::URLRequestContextGetter implementation. |
82 virtual net::URLRequestContext* GetURLRequestContext(); | 82 virtual net::URLRequestContext* GetURLRequestContext(); |
83 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; | 83 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; |
84 | 84 |
85 private: | 85 private: |
86 ~RequestContextGetter() {} | 86 virtual ~RequestContextGetter() {} |
87 | 87 |
88 // User agent to apply to the net::URLRequestContext. | 88 // User agent to apply to the net::URLRequestContext. |
89 std::string user_agent_; | 89 std::string user_agent_; |
90 | 90 |
91 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; | 91 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; |
92 | 92 |
93 // Lazily initialized by GetURLRequestContext(). | 93 // Lazily initialized by GetURLRequestContext(). |
94 scoped_refptr<RequestContext> context_; | 94 scoped_refptr<RequestContext> context_; |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); | 96 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 HttpBridge::RequestContextGetter* GetRequestContextGetter(); | 218 HttpBridge::RequestContextGetter* GetRequestContextGetter(); |
219 | 219 |
220 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; | 220 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; |
221 | 221 |
222 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); | 222 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); |
223 }; | 223 }; |
224 | 224 |
225 } // namespace browser_sync | 225 } // namespace browser_sync |
226 | 226 |
227 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ | 227 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ |
OLD | NEW |