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

Side by Side Diff: sync/internal_api/public/http_bridge.h

Issue 1330443002: Report data usage UMA for Chrome services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Fix calling Init function in sync_client.cc Created 5 years, 3 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
6 #define SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // This is a one-time use bridge. Create one for each request you want to make. 47 // This is a one-time use bridge. Create one for each request you want to make.
48 // It is RefCountedThreadSafe because it can PostTask to the io loop, and thus 48 // It is RefCountedThreadSafe because it can PostTask to the io loop, and thus
49 // needs to stick around across context switches, etc. 49 // needs to stick around across context switches, etc.
50 class SYNC_EXPORT_PRIVATE HttpBridge 50 class SYNC_EXPORT_PRIVATE HttpBridge
51 : public base::RefCountedThreadSafe<HttpBridge>, 51 : public base::RefCountedThreadSafe<HttpBridge>,
52 public HttpPostProviderInterface, 52 public HttpPostProviderInterface,
53 public net::URLFetcherDelegate { 53 public net::URLFetcherDelegate {
54 public: 54 public:
55 HttpBridge(const std::string& user_agent, 55 HttpBridge(const std::string& user_agent,
56 const scoped_refptr<net::URLRequestContextGetter>& context, 56 const scoped_refptr<net::URLRequestContextGetter>& context,
57 const NetworkTimeUpdateCallback& network_time_update_callback); 57 const NetworkTimeUpdateCallback& network_time_update_callback,
58 const BindToTrackerCallback& bind_to_tracker_callback);
58 59
59 // HttpPostProvider implementation. 60 // HttpPostProvider implementation.
60 void SetExtraRequestHeaders(const char* headers) override; 61 void SetExtraRequestHeaders(const char* headers) override;
61 void SetURL(const char* url, int port) override; 62 void SetURL(const char* url, int port) override;
62 void SetPostPayload(const char* content_type, 63 void SetPostPayload(const char* content_type,
63 int content_length, 64 int content_length,
64 const char* content) override; 65 const char* content) override;
65 bool MakeSynchronousPost(int* error_code, int* response_code) override; 66 bool MakeSynchronousPost(int* error_code, int* response_code) override;
66 void Abort() override; 67 void Abort() override;
67 68
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 mutable base::Lock fetch_state_lock_; 174 mutable base::Lock fetch_state_lock_;
174 URLFetchState fetch_state_; 175 URLFetchState fetch_state_;
175 176
176 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 177 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
177 178
178 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 179 const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
179 180
180 // Callback for updating network time. 181 // Callback for updating network time.
181 NetworkTimeUpdateCallback network_time_update_callback_; 182 NetworkTimeUpdateCallback network_time_update_callback_;
182 183
184 // A callback to tag Sync request to be able to record data use of this
185 // service by data_use_measurement component.
186 BindToTrackerCallback bind_to_tracker_callback_;
187
183 DISALLOW_COPY_AND_ASSIGN(HttpBridge); 188 DISALLOW_COPY_AND_ASSIGN(HttpBridge);
184 }; 189 };
185 190
186 class SYNC_EXPORT HttpBridgeFactory : public HttpPostProviderFactory, 191 class SYNC_EXPORT HttpBridgeFactory : public HttpPostProviderFactory,
187 public CancelationObserver { 192 public CancelationObserver {
188 public: 193 public:
189 HttpBridgeFactory( 194 HttpBridgeFactory(
190 const scoped_refptr<net::URLRequestContextGetter>& 195 const scoped_refptr<net::URLRequestContextGetter>&
191 baseline_context_getter, 196 baseline_context_getter,
192 const NetworkTimeUpdateCallback& network_time_update_callback, 197 const NetworkTimeUpdateCallback& network_time_update_callback,
193 CancelationSignal* cancelation_signal); 198 CancelationSignal* cancelation_signal);
194 ~HttpBridgeFactory() override; 199 ~HttpBridgeFactory() override;
195 200
196 // HttpPostProviderFactory: 201 // HttpPostProviderFactory:
197 void Init(const std::string& user_agent) override; 202 void Init(const std::string& user_agent,
203 const BindToTrackerCallback& bind_to_tracker_callback) override;
198 HttpPostProviderInterface* Create() override; 204 HttpPostProviderInterface* Create() override;
199 void Destroy(HttpPostProviderInterface* http) override; 205 void Destroy(HttpPostProviderInterface* http) override;
200 206
201 // CancelationObserver implementation: 207 // CancelationObserver implementation:
202 void OnSignalReceived() override; 208 void OnSignalReceived() override;
203 209
204 private: 210 private:
205 // The user agent to use in all requests. 211 // The user agent to use in all requests.
206 std::string user_agent_; 212 std::string user_agent_;
207 213
208 // Protects |request_context_getter_| to allow releasing it's reference from 214 // Protects |request_context_getter_| to allow releasing it's reference from
209 // the sync thread, even when it's in use on the IO thread. 215 // the sync thread, even when it's in use on the IO thread.
210 base::Lock request_context_getter_lock_; 216 base::Lock request_context_getter_lock_;
211 217
212 // The request context getter used for making all requests. 218 // The request context getter used for making all requests.
213 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 219 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
214 220
215 NetworkTimeUpdateCallback network_time_update_callback_; 221 NetworkTimeUpdateCallback network_time_update_callback_;
216 222
217 CancelationSignal* const cancelation_signal_; 223 CancelationSignal* const cancelation_signal_;
218 224
225 // A callback to tag Sync request to be able to record data use of this
226 // service by data_use_measurement component.
227 BindToTrackerCallback bind_to_tracker_callback_;
228
219 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory); 229 DISALLOW_COPY_AND_ASSIGN(HttpBridgeFactory);
220 }; 230 };
221 231
222 } // namespace syncer 232 } // namespace syncer
223 233
224 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_ 234 #endif // SYNC_INTERNAL_API_PUBLIC_HTTP_BRIDGE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/http_bridge_unittest.cc ('k') | sync/internal_api/public/http_post_provider_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698