| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ | 5 #ifndef CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ |
| 6 #define CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ | 6 #define CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Called when a new geo timezone information is available. | 62 // Called when a new geo timezone information is available. |
| 63 // The second argument indicates whether there was a server error or not. | 63 // The second argument indicates whether there was a server error or not. |
| 64 // It is true when there was a server or network error - either no response | 64 // It is true when there was a server or network error - either no response |
| 65 // or a 500 error code. | 65 // or a 500 error code. |
| 66 typedef base::Callback<void(scoped_ptr<TimeZoneResponseData> /* timezone */, | 66 typedef base::Callback<void(scoped_ptr<TimeZoneResponseData> /* timezone */, |
| 67 bool /* server_error */)> | 67 bool /* server_error */)> |
| 68 TimeZoneResponseCallback; | 68 TimeZoneResponseCallback; |
| 69 | 69 |
| 70 // |url| is the server address to which the request wil be sent. | 70 // |url| is the server address to which the request wil be sent. |
| 71 // |geoposition| is the location to query timezone for. | 71 // |geoposition| is the location to query timezone for. |
| 72 // |sensor| if this location was determined using hardware sensor. | |
| 73 // |retry_timeout| retry request on error until timeout. | 72 // |retry_timeout| retry request on error until timeout. |
| 74 TimeZoneRequest(net::URLRequestContextGetter* url_context_getter, | 73 TimeZoneRequest(net::URLRequestContextGetter* url_context_getter, |
| 75 const GURL& service_url, | 74 const GURL& service_url, |
| 76 const Geoposition& geoposition, | 75 const Geoposition& geoposition, |
| 77 bool sensor, | |
| 78 base::TimeDelta retry_timeout); | 76 base::TimeDelta retry_timeout); |
| 79 | 77 |
| 80 virtual ~TimeZoneRequest(); | 78 virtual ~TimeZoneRequest(); |
| 81 | 79 |
| 82 // Initiates request. | 80 // Initiates request. |
| 83 // Note: if request object is destroyed before callback is called, | 81 // Note: if request object is destroyed before callback is called, |
| 84 // request will be silently cancelled. | 82 // request will be silently cancelled. |
| 85 void MakeRequest(TimeZoneResponseCallback callback); | 83 void MakeRequest(TimeZoneResponseCallback callback); |
| 86 | 84 |
| 87 void set_retry_sleep_on_server_error_for_testing( | 85 void set_retry_sleep_on_server_error_for_testing( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 100 | 98 |
| 101 // Start new request. | 99 // Start new request. |
| 102 void StartRequest(); | 100 void StartRequest(); |
| 103 | 101 |
| 104 // Schedules retry. | 102 // Schedules retry. |
| 105 void Retry(bool server_error); | 103 void Retry(bool server_error); |
| 106 | 104 |
| 107 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; | 105 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; |
| 108 const GURL service_url_; | 106 const GURL service_url_; |
| 109 Geoposition geoposition_; | 107 Geoposition geoposition_; |
| 110 const bool sensor_; | |
| 111 | 108 |
| 112 TimeZoneResponseCallback callback_; | 109 TimeZoneResponseCallback callback_; |
| 113 | 110 |
| 114 GURL request_url_; | 111 GURL request_url_; |
| 115 scoped_ptr<net::URLFetcher> url_fetcher_; | 112 scoped_ptr<net::URLFetcher> url_fetcher_; |
| 116 | 113 |
| 117 // When request was actually started. | 114 // When request was actually started. |
| 118 base::Time request_started_at_; | 115 base::Time request_started_at_; |
| 119 | 116 |
| 120 // Absolute time, when it is passed no more retry requests are allowed. | 117 // Absolute time, when it is passed no more retry requests are allowed. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 132 | 129 |
| 133 // Creation and destruction should happen on the same thread. | 130 // Creation and destruction should happen on the same thread. |
| 134 base::ThreadChecker thread_checker_; | 131 base::ThreadChecker thread_checker_; |
| 135 | 132 |
| 136 DISALLOW_COPY_AND_ASSIGN(TimeZoneRequest); | 133 DISALLOW_COPY_AND_ASSIGN(TimeZoneRequest); |
| 137 }; | 134 }; |
| 138 | 135 |
| 139 } // namespace chromeos | 136 } // namespace chromeos |
| 140 | 137 |
| 141 #endif // CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ | 138 #endif // CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ |
| OLD | NEW |