OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 }; | 236 }; |
237 | 237 |
238 class PrivetHTTPClientImpl : public PrivetHTTPClient { | 238 class PrivetHTTPClientImpl : public PrivetHTTPClient { |
239 public: | 239 public: |
240 PrivetHTTPClientImpl( | 240 PrivetHTTPClientImpl( |
241 const std::string& name, | 241 const std::string& name, |
242 const net::HostPortPair& host_port, | 242 const net::HostPortPair& host_port, |
243 net::URLRequestContextGetter* request_context); | 243 net::URLRequestContextGetter* request_context); |
244 virtual ~PrivetHTTPClientImpl(); | 244 virtual ~PrivetHTTPClientImpl(); |
245 | 245 |
246 virtual const base::DictionaryValue* GetCachedInfo() const OVERRIDE; | |
247 | |
248 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( | 246 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( |
249 const std::string& user, | 247 const std::string& user, |
250 PrivetRegisterOperation::Delegate* delegate) OVERRIDE; | 248 PrivetRegisterOperation::Delegate* delegate) OVERRIDE; |
251 | 249 |
252 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( | 250 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( |
253 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 251 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; |
254 | 252 |
255 virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation( | 253 virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation( |
256 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 254 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; |
257 | 255 |
258 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( | 256 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( |
259 PrivetLocalPrintOperation::Delegate* delegate) OVERRIDE; | 257 PrivetLocalPrintOperation::Delegate* delegate) OVERRIDE; |
260 | 258 |
261 virtual scoped_ptr<PrivetJSONOperation> CreateStorageListOperation( | 259 virtual scoped_ptr<PrivetJSONOperation> CreateStorageListOperation( |
262 const std::string& path, | 260 const std::string& path, |
263 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 261 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; |
264 | 262 |
265 virtual const std::string& GetName() OVERRIDE; | 263 virtual const std::string& GetName() OVERRIDE; |
266 | 264 |
267 scoped_ptr<PrivetURLFetcher> CreateURLFetcher( | 265 scoped_ptr<PrivetURLFetcher> CreateURLFetcher( |
268 const GURL& url, | 266 const GURL& url, |
269 net::URLFetcher::RequestType request_type, | 267 net::URLFetcher::RequestType request_type, |
270 PrivetURLFetcher::Delegate* delegate) const; | 268 PrivetURLFetcher::Delegate* delegate) const; |
271 | 269 |
272 void CacheInfo(const base::DictionaryValue* cached_info); | |
273 | |
274 bool HasToken() const; | |
275 | |
276 void RefreshPrivetToken( | 270 void RefreshPrivetToken( |
277 const PrivetURLFetcher::TokenCallback& token_callback); | 271 const PrivetURLFetcher::TokenCallback& token_callback); |
278 | 272 |
279 private: | 273 private: |
280 typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector; | 274 typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector; |
281 | 275 |
282 void OnPrivetInfoDone(const base::DictionaryValue* value); | 276 void OnPrivetInfoDone(const base::DictionaryValue* value); |
283 | 277 |
284 std::string name_; | 278 std::string name_; |
285 PrivetURLFetcherFactory fetcher_factory_; | 279 scoped_refptr<net::URLRequestContextGetter> request_context_; |
286 net::HostPortPair host_port_; | 280 net::HostPortPair host_port_; |
287 scoped_ptr<base::DictionaryValue> cached_info_; | |
288 | 281 |
289 scoped_ptr<PrivetJSONOperation> info_operation_; | 282 scoped_ptr<PrivetJSONOperation> info_operation_; |
290 TokenCallbackVector token_callbacks_; | 283 TokenCallbackVector token_callbacks_; |
291 }; | 284 }; |
292 | 285 |
293 } // namespace local_discovery | 286 } // namespace local_discovery |
294 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 287 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
OLD | NEW |