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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // |retry_timeout| retry request on error until timeout. | 72 // |retry_timeout| retry request on error until timeout. |
73 TimeZoneRequest(net::URLRequestContextGetter* url_context_getter, | 73 TimeZoneRequest(net::URLRequestContextGetter* url_context_getter, |
74 const GURL& service_url, | 74 const GURL& service_url, |
75 const Geoposition& geoposition, | 75 const Geoposition& geoposition, |
76 base::TimeDelta retry_timeout); | 76 base::TimeDelta retry_timeout); |
77 | 77 |
78 virtual ~TimeZoneRequest(); | 78 ~TimeZoneRequest() override; |
79 | 79 |
80 // Initiates request. | 80 // Initiates request. |
81 // Note: if request object is destroyed before callback is called, | 81 // Note: if request object is destroyed before callback is called, |
82 // request will be silently cancelled. | 82 // request will be silently cancelled. |
83 void MakeRequest(TimeZoneResponseCallback callback); | 83 void MakeRequest(TimeZoneResponseCallback callback); |
84 | 84 |
85 void set_retry_sleep_on_server_error_for_testing( | 85 void set_retry_sleep_on_server_error_for_testing( |
86 const base::TimeDelta value) { | 86 const base::TimeDelta value) { |
87 retry_sleep_on_server_error_ = value; | 87 retry_sleep_on_server_error_ = value; |
88 } | 88 } |
89 | 89 |
90 void set_retry_sleep_on_bad_response_for_testing( | 90 void set_retry_sleep_on_bad_response_for_testing( |
91 const base::TimeDelta value) { | 91 const base::TimeDelta value) { |
92 retry_sleep_on_bad_response_ = value; | 92 retry_sleep_on_bad_response_ = value; |
93 } | 93 } |
94 | 94 |
95 private: | 95 private: |
96 // net::URLFetcherDelegate | 96 // net::URLFetcherDelegate |
97 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 97 void OnURLFetchComplete(const net::URLFetcher* source) override; |
98 | 98 |
99 // Start new request. | 99 // Start new request. |
100 void StartRequest(); | 100 void StartRequest(); |
101 | 101 |
102 // Schedules retry. | 102 // Schedules retry. |
103 void Retry(bool server_error); | 103 void Retry(bool server_error); |
104 | 104 |
105 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; | 105 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; |
106 const GURL service_url_; | 106 const GURL service_url_; |
107 Geoposition geoposition_; | 107 Geoposition geoposition_; |
(...skipping 21 matching lines...) Expand all Loading... |
129 | 129 |
130 // Creation and destruction should happen on the same thread. | 130 // Creation and destruction should happen on the same thread. |
131 base::ThreadChecker thread_checker_; | 131 base::ThreadChecker thread_checker_; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(TimeZoneRequest); | 133 DISALLOW_COPY_AND_ASSIGN(TimeZoneRequest); |
134 }; | 134 }; |
135 | 135 |
136 } // namespace chromeos | 136 } // namespace chromeos |
137 | 137 |
138 #endif // CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ | 138 #endif // CHROMEOS_TIMEZONE_TIMEZONE_REQUEST_H_ |
OLD | NEW |