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

Side by Side Diff: chrome/browser/sync/glue/http_bridge.h

Issue 8470005: Add OVERRIDE to chrome/browser/sync/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: includes Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // |baseline_context| is used to obtain the accept-language, 48 // |baseline_context| is used to obtain the accept-language,
49 // accept-charsets, and proxy service information for bridged requests. 49 // accept-charsets, and proxy service information for bridged requests.
50 // Typically |baseline_context| should be the net::URLRequestContext of the 50 // Typically |baseline_context| should be the net::URLRequestContext of the
51 // currently active profile. 51 // currently active profile.
52 explicit RequestContext(net::URLRequestContext* baseline_context); 52 explicit RequestContext(net::URLRequestContext* baseline_context);
53 53
54 // Set the user agent for requests using this context. The default is 54 // Set the user agent for requests using this context. The default is
55 // the browser's UA string. 55 // the browser's UA string.
56 void set_user_agent(const std::string& ua) { user_agent_ = ua; } 56 void set_user_agent(const std::string& ua) { user_agent_ = ua; }
57 57
58 virtual const std::string& GetUserAgent(const GURL& url) const { 58 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE {
59 // If the user agent is set explicitly return that, otherwise call the 59 // If the user agent is set explicitly return that, otherwise call the
60 // base class method to return default value. 60 // base class method to return default value.
61 return user_agent_.empty() ? 61 return user_agent_.empty() ?
62 net::URLRequestContext::GetUserAgent(url) : user_agent_; 62 net::URLRequestContext::GetUserAgent(url) : user_agent_;
63 } 63 }
64 64
65 private: 65 private:
66 // The destructor MUST be called on the IO thread. 66 // The destructor MUST be called on the IO thread.
67 virtual ~RequestContext(); 67 virtual ~RequestContext();
68 68
69 std::string user_agent_; 69 std::string user_agent_;
70 net::URLRequestContext* baseline_context_; 70 net::URLRequestContext* baseline_context_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(RequestContext); 72 DISALLOW_COPY_AND_ASSIGN(RequestContext);
73 }; 73 };
74 74
75 // Lazy-getter for RequestContext objects. 75 // Lazy-getter for RequestContext objects.
76 class RequestContextGetter : public net::URLRequestContextGetter { 76 class RequestContextGetter : public net::URLRequestContextGetter {
77 public: 77 public:
78 explicit RequestContextGetter( 78 explicit RequestContextGetter(
79 net::URLRequestContextGetter* baseline_context_getter); 79 net::URLRequestContextGetter* baseline_context_getter);
80 80
81 void set_user_agent(const std::string& ua) { user_agent_ = ua; } 81 void set_user_agent(const std::string& ua) { user_agent_ = ua; }
82 bool is_user_agent_set() const { return !user_agent_.empty(); } 82 bool is_user_agent_set() const { return !user_agent_.empty(); }
83 83
84 // net::URLRequestContextGetter implementation. 84 // net::URLRequestContextGetter implementation.
85 virtual net::URLRequestContext* GetURLRequestContext(); 85 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
86 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; 86 virtual scoped_refptr<base::MessageLoopProxy>
87 GetIOMessageLoopProxy() const OVERRIDE;
87 88
88 private: 89 private:
89 virtual ~RequestContextGetter() {} 90 virtual ~RequestContextGetter() {}
90 91
91 // User agent to apply to the net::URLRequestContext. 92 // User agent to apply to the net::URLRequestContext.
92 std::string user_agent_; 93 std::string user_agent_;
93 94
94 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_; 95 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter_;
95 96
96 // Lazily initialized by GetURLRequestContext(). 97 // Lazily initialized by GetURLRequestContext().
97 scoped_refptr<RequestContext> context_; 98 scoped_refptr<RequestContext> context_;
98 99
99 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter); 100 DISALLOW_COPY_AND_ASSIGN(RequestContextGetter);
100 }; 101 };
101 102
102 explicit HttpBridge(RequestContextGetter* context); 103 explicit HttpBridge(RequestContextGetter* context);
103 104
104 // sync_api::HttpPostProvider implementation. 105 // sync_api::HttpPostProvider implementation.
105 virtual void SetUserAgent(const char* user_agent); 106 virtual void SetUserAgent(const char* user_agent) OVERRIDE;
106 virtual void SetExtraRequestHeaders(const char* headers); 107 virtual void SetExtraRequestHeaders(const char* headers) OVERRIDE;
107 virtual void SetURL(const char* url, int port); 108 virtual void SetURL(const char* url, int port) OVERRIDE;
108 virtual void SetPostPayload(const char* content_type, int content_length, 109 virtual void SetPostPayload(const char* content_type, int content_length,
109 const char* content); 110 const char* content) OVERRIDE;
110 virtual bool MakeSynchronousPost(int* error_code, int* response_code); 111 virtual bool MakeSynchronousPost(int* error_code,
111 virtual void Abort(); 112 int* response_code) OVERRIDE;
113 virtual void Abort() OVERRIDE;
112 114
113 // WARNING: these response content methods are used to extract plain old data 115 // WARNING: these response content methods are used to extract plain old data
114 // and not null terminated strings, so you should make sure you have read 116 // and not null terminated strings, so you should make sure you have read
115 // GetResponseContentLength() characters when using GetResponseContent. e.g 117 // GetResponseContentLength() characters when using GetResponseContent. e.g
116 // string r(b->GetResponseContent(), b->GetResponseContentLength()). 118 // string r(b->GetResponseContent(), b->GetResponseContentLength()).
117 virtual int GetResponseContentLength() const; 119 virtual int GetResponseContentLength() const OVERRIDE;
118 virtual const char* GetResponseContent() const; 120 virtual const char* GetResponseContent() const OVERRIDE;
119 virtual const std::string GetResponseHeaderValue( 121 virtual const std::string GetResponseHeaderValue(
120 const std::string& name) const; 122 const std::string& name) const OVERRIDE;
121 123
122 // content::URLFetcherDelegate implementation. 124 // content::URLFetcherDelegate implementation.
123 virtual void OnURLFetchComplete(const content::URLFetcher* source); 125 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
124 126
125 #if defined(UNIT_TEST) 127 #if defined(UNIT_TEST)
126 net::URLRequestContextGetter* GetRequestContextGetter() const { 128 net::URLRequestContextGetter* GetRequestContextGetter() const {
127 return context_getter_for_request_; 129 return context_getter_for_request_;
128 } 130 }
129 #endif 131 #endif
130 132
131 protected: 133 protected:
132 friend class base::RefCountedThreadSafe<HttpBridge>; 134 friend class base::RefCountedThreadSafe<HttpBridge>;
133 135
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 HttpBridge::RequestContextGetter* GetRequestContextGetter(); 218 HttpBridge::RequestContextGetter* GetRequestContextGetter();
217 219
218 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_; 220 scoped_refptr<HttpBridge::RequestContextGetter> request_context_getter_;
219 221
220 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); 222 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory);
221 }; 223 };
222 224
223 } // namespace browser_sync 225 } // namespace browser_sync
224 226
225 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_ 227 #endif // CHROME_BROWSER_SYNC_GLUE_HTTP_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698