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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class PrivetHTTPClient; | 25 class PrivetHTTPClient; |
26 | 26 |
27 class PrivetInfoOperationImpl : public PrivetJSONOperation, | 27 class PrivetInfoOperationImpl : public PrivetJSONOperation, |
28 public PrivetURLFetcher::Delegate { | 28 public PrivetURLFetcher::Delegate { |
29 public: | 29 public: |
30 PrivetInfoOperationImpl(PrivetHTTPClient* privet_client, | 30 PrivetInfoOperationImpl(PrivetHTTPClient* privet_client, |
31 const PrivetJSONOperation::ResultCallback& callback); | 31 const PrivetJSONOperation::ResultCallback& callback); |
32 virtual ~PrivetInfoOperationImpl(); | 32 virtual ~PrivetInfoOperationImpl(); |
33 | 33 |
34 virtual void Start() OVERRIDE; | 34 virtual void Start() override; |
35 | 35 |
36 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 36 virtual PrivetHTTPClient* GetHTTPClient() override; |
37 | 37 |
38 virtual void OnError(PrivetURLFetcher* fetcher, | 38 virtual void OnError(PrivetURLFetcher* fetcher, |
39 PrivetURLFetcher::ErrorType error) OVERRIDE; | 39 PrivetURLFetcher::ErrorType error) override; |
40 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 40 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
41 const base::DictionaryValue& value, | 41 const base::DictionaryValue& value, |
42 bool has_error) OVERRIDE; | 42 bool has_error) override; |
43 | 43 |
44 private: | 44 private: |
45 PrivetHTTPClient* privet_client_; | 45 PrivetHTTPClient* privet_client_; |
46 PrivetJSONOperation::ResultCallback callback_; | 46 PrivetJSONOperation::ResultCallback callback_; |
47 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 47 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
48 }; | 48 }; |
49 | 49 |
50 class PrivetRegisterOperationImpl | 50 class PrivetRegisterOperationImpl |
51 : public PrivetRegisterOperation, | 51 : public PrivetRegisterOperation, |
52 public PrivetURLFetcher::Delegate, | 52 public PrivetURLFetcher::Delegate, |
53 public base::SupportsWeakPtr<PrivetRegisterOperationImpl> { | 53 public base::SupportsWeakPtr<PrivetRegisterOperationImpl> { |
54 public: | 54 public: |
55 PrivetRegisterOperationImpl(PrivetHTTPClient* privet_client, | 55 PrivetRegisterOperationImpl(PrivetHTTPClient* privet_client, |
56 const std::string& user, | 56 const std::string& user, |
57 PrivetRegisterOperation::Delegate* delegate); | 57 PrivetRegisterOperation::Delegate* delegate); |
58 virtual ~PrivetRegisterOperationImpl(); | 58 virtual ~PrivetRegisterOperationImpl(); |
59 | 59 |
60 virtual void Start() OVERRIDE; | 60 virtual void Start() override; |
61 virtual void Cancel() OVERRIDE; | 61 virtual void Cancel() override; |
62 virtual void CompleteRegistration() OVERRIDE; | 62 virtual void CompleteRegistration() override; |
63 | 63 |
64 virtual void OnError(PrivetURLFetcher* fetcher, | 64 virtual void OnError(PrivetURLFetcher* fetcher, |
65 PrivetURLFetcher::ErrorType error) OVERRIDE; | 65 PrivetURLFetcher::ErrorType error) override; |
66 | 66 |
67 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 67 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
68 const base::DictionaryValue& value, | 68 const base::DictionaryValue& value, |
69 bool has_error) OVERRIDE; | 69 bool has_error) override; |
70 | 70 |
71 virtual void OnNeedPrivetToken( | 71 virtual void OnNeedPrivetToken( |
72 PrivetURLFetcher* fetcher, | 72 PrivetURLFetcher* fetcher, |
73 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; | 73 const PrivetURLFetcher::TokenCallback& callback) override; |
74 | 74 |
75 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 75 virtual PrivetHTTPClient* GetHTTPClient() override; |
76 private: | 76 private: |
77 class Cancelation : public PrivetURLFetcher::Delegate { | 77 class Cancelation : public PrivetURLFetcher::Delegate { |
78 public: | 78 public: |
79 Cancelation(PrivetHTTPClient* privet_client, const std::string& user); | 79 Cancelation(PrivetHTTPClient* privet_client, const std::string& user); |
80 virtual ~Cancelation(); | 80 virtual ~Cancelation(); |
81 | 81 |
82 virtual void OnError(PrivetURLFetcher* fetcher, | 82 virtual void OnError(PrivetURLFetcher* fetcher, |
83 PrivetURLFetcher::ErrorType error) OVERRIDE; | 83 PrivetURLFetcher::ErrorType error) override; |
84 | 84 |
85 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 85 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
86 const base::DictionaryValue& value, | 86 const base::DictionaryValue& value, |
87 bool has_error) OVERRIDE; | 87 bool has_error) override; |
88 | 88 |
89 void Cleanup(); | 89 void Cleanup(); |
90 | 90 |
91 private: | 91 private: |
92 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 92 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
93 }; | 93 }; |
94 | 94 |
95 // Arguments is JSON value from request. | 95 // Arguments is JSON value from request. |
96 typedef base::Callback<void(const base::DictionaryValue&)> | 96 typedef base::Callback<void(const base::DictionaryValue&)> |
97 ResponseHandler; | 97 ResponseHandler; |
(...skipping 22 matching lines...) Expand all Loading... |
120 }; | 120 }; |
121 | 121 |
122 class PrivetJSONOperationImpl : public PrivetJSONOperation, | 122 class PrivetJSONOperationImpl : public PrivetJSONOperation, |
123 public PrivetURLFetcher::Delegate { | 123 public PrivetURLFetcher::Delegate { |
124 public: | 124 public: |
125 PrivetJSONOperationImpl(PrivetHTTPClient* privet_client, | 125 PrivetJSONOperationImpl(PrivetHTTPClient* privet_client, |
126 const std::string& path, | 126 const std::string& path, |
127 const std::string& query_params, | 127 const std::string& query_params, |
128 const PrivetJSONOperation::ResultCallback& callback); | 128 const PrivetJSONOperation::ResultCallback& callback); |
129 virtual ~PrivetJSONOperationImpl(); | 129 virtual ~PrivetJSONOperationImpl(); |
130 virtual void Start() OVERRIDE; | 130 virtual void Start() override; |
131 | 131 |
132 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 132 virtual PrivetHTTPClient* GetHTTPClient() override; |
133 | 133 |
134 virtual void OnError(PrivetURLFetcher* fetcher, | 134 virtual void OnError(PrivetURLFetcher* fetcher, |
135 PrivetURLFetcher::ErrorType error) OVERRIDE; | 135 PrivetURLFetcher::ErrorType error) override; |
136 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 136 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
137 const base::DictionaryValue& value, | 137 const base::DictionaryValue& value, |
138 bool has_error) OVERRIDE; | 138 bool has_error) override; |
139 virtual void OnNeedPrivetToken( | 139 virtual void OnNeedPrivetToken( |
140 PrivetURLFetcher* fetcher, | 140 PrivetURLFetcher* fetcher, |
141 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; | 141 const PrivetURLFetcher::TokenCallback& callback) override; |
142 | 142 |
143 private: | 143 private: |
144 PrivetHTTPClient* privet_client_; | 144 PrivetHTTPClient* privet_client_; |
145 std::string path_; | 145 std::string path_; |
146 std::string query_params_; | 146 std::string query_params_; |
147 PrivetJSONOperation::ResultCallback callback_; | 147 PrivetJSONOperation::ResultCallback callback_; |
148 | 148 |
149 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 149 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
150 }; | 150 }; |
151 | 151 |
152 class PrivetDataReadOperationImpl : public PrivetDataReadOperation, | 152 class PrivetDataReadOperationImpl : public PrivetDataReadOperation, |
153 public PrivetURLFetcher::Delegate { | 153 public PrivetURLFetcher::Delegate { |
154 public: | 154 public: |
155 PrivetDataReadOperationImpl( | 155 PrivetDataReadOperationImpl( |
156 PrivetHTTPClient* privet_client, | 156 PrivetHTTPClient* privet_client, |
157 const std::string& path, | 157 const std::string& path, |
158 const std::string& query_params, | 158 const std::string& query_params, |
159 const PrivetDataReadOperation::ResultCallback& callback); | 159 const PrivetDataReadOperation::ResultCallback& callback); |
160 virtual ~PrivetDataReadOperationImpl(); | 160 virtual ~PrivetDataReadOperationImpl(); |
161 | 161 |
162 virtual void Start() OVERRIDE; | 162 virtual void Start() override; |
163 | 163 |
164 virtual void SetDataRange(int range_start, int range_end) OVERRIDE; | 164 virtual void SetDataRange(int range_start, int range_end) override; |
165 | 165 |
166 virtual void SaveDataToFile() OVERRIDE; | 166 virtual void SaveDataToFile() override; |
167 | 167 |
168 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 168 virtual PrivetHTTPClient* GetHTTPClient() override; |
169 | 169 |
170 virtual void OnError(PrivetURLFetcher* fetcher, | 170 virtual void OnError(PrivetURLFetcher* fetcher, |
171 PrivetURLFetcher::ErrorType error) OVERRIDE; | 171 PrivetURLFetcher::ErrorType error) override; |
172 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 172 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
173 const base::DictionaryValue& value, | 173 const base::DictionaryValue& value, |
174 bool has_error) OVERRIDE; | 174 bool has_error) override; |
175 virtual void OnNeedPrivetToken( | 175 virtual void OnNeedPrivetToken( |
176 PrivetURLFetcher* fetcher, | 176 PrivetURLFetcher* fetcher, |
177 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; | 177 const PrivetURLFetcher::TokenCallback& callback) override; |
178 virtual bool OnRawData(PrivetURLFetcher* fetcher, | 178 virtual bool OnRawData(PrivetURLFetcher* fetcher, |
179 bool is_file, | 179 bool is_file, |
180 const std::string& data_str, | 180 const std::string& data_str, |
181 const base::FilePath& file_path) OVERRIDE; | 181 const base::FilePath& file_path) override; |
182 | 182 |
183 private: | 183 private: |
184 PrivetHTTPClient* privet_client_; | 184 PrivetHTTPClient* privet_client_; |
185 std::string path_; | 185 std::string path_; |
186 std::string query_params_; | 186 std::string query_params_; |
187 int range_start_; | 187 int range_start_; |
188 int range_end_; | 188 int range_end_; |
189 PrivetDataReadOperation::ResultCallback callback_; | 189 PrivetDataReadOperation::ResultCallback callback_; |
190 | 190 |
191 bool has_range_; | 191 bool has_range_; |
192 bool save_to_file_; | 192 bool save_to_file_; |
193 | 193 |
194 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 194 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
195 }; | 195 }; |
196 | 196 |
197 #if defined(ENABLE_FULL_PRINTING) | 197 #if defined(ENABLE_FULL_PRINTING) |
198 class PrivetLocalPrintOperationImpl | 198 class PrivetLocalPrintOperationImpl |
199 : public PrivetLocalPrintOperation, | 199 : public PrivetLocalPrintOperation, |
200 public PrivetURLFetcher::Delegate { | 200 public PrivetURLFetcher::Delegate { |
201 public: | 201 public: |
202 PrivetLocalPrintOperationImpl(PrivetHTTPClient* privet_client, | 202 PrivetLocalPrintOperationImpl(PrivetHTTPClient* privet_client, |
203 PrivetLocalPrintOperation::Delegate* delegate); | 203 PrivetLocalPrintOperation::Delegate* delegate); |
204 | 204 |
205 virtual ~PrivetLocalPrintOperationImpl(); | 205 virtual ~PrivetLocalPrintOperationImpl(); |
206 virtual void Start() OVERRIDE; | 206 virtual void Start() override; |
207 | 207 |
208 virtual void SetData( | 208 virtual void SetData( |
209 const scoped_refptr<base::RefCountedBytes>& data) OVERRIDE; | 209 const scoped_refptr<base::RefCountedBytes>& data) override; |
210 | 210 |
211 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; | 211 virtual void SetCapabilities(const std::string& capabilities) override; |
212 | 212 |
213 virtual void SetTicket(const std::string& ticket) OVERRIDE; | 213 virtual void SetTicket(const std::string& ticket) override; |
214 | 214 |
215 virtual void SetUsername(const std::string& user) OVERRIDE; | 215 virtual void SetUsername(const std::string& user) override; |
216 | 216 |
217 virtual void SetJobname(const std::string& jobname) OVERRIDE; | 217 virtual void SetJobname(const std::string& jobname) override; |
218 | 218 |
219 virtual void SetOffline(bool offline) OVERRIDE; | 219 virtual void SetOffline(bool offline) override; |
220 | 220 |
221 virtual void SetPageSize(const gfx::Size& page_size) OVERRIDE; | 221 virtual void SetPageSize(const gfx::Size& page_size) override; |
222 | 222 |
223 virtual void SetPWGRasterConverterForTesting( | 223 virtual void SetPWGRasterConverterForTesting( |
224 scoped_ptr<PWGRasterConverter> pwg_raster_converter) OVERRIDE; | 224 scoped_ptr<PWGRasterConverter> pwg_raster_converter) override; |
225 | 225 |
226 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 226 virtual PrivetHTTPClient* GetHTTPClient() override; |
227 | 227 |
228 virtual void OnError(PrivetURLFetcher* fetcher, | 228 virtual void OnError(PrivetURLFetcher* fetcher, |
229 PrivetURLFetcher::ErrorType error) OVERRIDE; | 229 PrivetURLFetcher::ErrorType error) override; |
230 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 230 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
231 const base::DictionaryValue& value, | 231 const base::DictionaryValue& value, |
232 bool has_error) OVERRIDE; | 232 bool has_error) override; |
233 virtual void OnNeedPrivetToken( | 233 virtual void OnNeedPrivetToken( |
234 PrivetURLFetcher* fetcher, | 234 PrivetURLFetcher* fetcher, |
235 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; | 235 const PrivetURLFetcher::TokenCallback& callback) override; |
236 | 236 |
237 private: | 237 private: |
238 typedef base::Callback<void(bool, const base::DictionaryValue* value)> | 238 typedef base::Callback<void(bool, const base::DictionaryValue* value)> |
239 ResponseCallback; | 239 ResponseCallback; |
240 | 240 |
241 void StartInitialRequest(); | 241 void StartInitialRequest(); |
242 void DoCreatejob(); | 242 void DoCreatejob(); |
243 void DoSubmitdoc(); | 243 void DoSubmitdoc(); |
244 | 244 |
245 void StartConvertToPWG(); | 245 void StartConvertToPWG(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 class PrivetHTTPClientImpl : public PrivetHTTPClient { | 289 class PrivetHTTPClientImpl : public PrivetHTTPClient { |
290 public: | 290 public: |
291 PrivetHTTPClientImpl( | 291 PrivetHTTPClientImpl( |
292 const std::string& name, | 292 const std::string& name, |
293 const net::HostPortPair& host_port, | 293 const net::HostPortPair& host_port, |
294 net::URLRequestContextGetter* request_context); | 294 net::URLRequestContextGetter* request_context); |
295 virtual ~PrivetHTTPClientImpl(); | 295 virtual ~PrivetHTTPClientImpl(); |
296 | 296 |
297 // PrivetHTTPClient implementation. | 297 // PrivetHTTPClient implementation. |
298 virtual const std::string& GetName() OVERRIDE; | 298 virtual const std::string& GetName() override; |
299 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( | 299 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( |
300 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 300 const PrivetJSONOperation::ResultCallback& callback) override; |
301 virtual scoped_ptr<PrivetURLFetcher> CreateURLFetcher( | 301 virtual scoped_ptr<PrivetURLFetcher> CreateURLFetcher( |
302 const GURL& url, | 302 const GURL& url, |
303 net::URLFetcher::RequestType request_type, | 303 net::URLFetcher::RequestType request_type, |
304 PrivetURLFetcher::Delegate* delegate) OVERRIDE; | 304 PrivetURLFetcher::Delegate* delegate) override; |
305 virtual void RefreshPrivetToken( | 305 virtual void RefreshPrivetToken( |
306 const PrivetURLFetcher::TokenCallback& token_callback) OVERRIDE; | 306 const PrivetURLFetcher::TokenCallback& token_callback) override; |
307 | 307 |
308 private: | 308 private: |
309 typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector; | 309 typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector; |
310 | 310 |
311 void OnPrivetInfoDone(const base::DictionaryValue* value); | 311 void OnPrivetInfoDone(const base::DictionaryValue* value); |
312 | 312 |
313 std::string name_; | 313 std::string name_; |
314 scoped_refptr<net::URLRequestContextGetter> request_context_; | 314 scoped_refptr<net::URLRequestContextGetter> request_context_; |
315 net::HostPortPair host_port_; | 315 net::HostPortPair host_port_; |
316 | 316 |
317 scoped_ptr<PrivetJSONOperation> info_operation_; | 317 scoped_ptr<PrivetJSONOperation> info_operation_; |
318 TokenCallbackVector token_callbacks_; | 318 TokenCallbackVector token_callbacks_; |
319 | 319 |
320 DISALLOW_COPY_AND_ASSIGN(PrivetHTTPClientImpl); | 320 DISALLOW_COPY_AND_ASSIGN(PrivetHTTPClientImpl); |
321 }; | 321 }; |
322 | 322 |
323 class PrivetV1HTTPClientImpl : public PrivetV1HTTPClient { | 323 class PrivetV1HTTPClientImpl : public PrivetV1HTTPClient { |
324 public: | 324 public: |
325 explicit PrivetV1HTTPClientImpl(scoped_ptr<PrivetHTTPClient> info_client); | 325 explicit PrivetV1HTTPClientImpl(scoped_ptr<PrivetHTTPClient> info_client); |
326 virtual ~PrivetV1HTTPClientImpl(); | 326 virtual ~PrivetV1HTTPClientImpl(); |
327 | 327 |
328 virtual const std::string& GetName() OVERRIDE; | 328 virtual const std::string& GetName() override; |
329 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( | 329 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( |
330 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 330 const PrivetJSONOperation::ResultCallback& callback) override; |
331 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( | 331 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( |
332 const std::string& user, | 332 const std::string& user, |
333 PrivetRegisterOperation::Delegate* delegate) OVERRIDE; | 333 PrivetRegisterOperation::Delegate* delegate) override; |
334 virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation( | 334 virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation( |
335 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 335 const PrivetJSONOperation::ResultCallback& callback) override; |
336 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( | 336 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( |
337 PrivetLocalPrintOperation::Delegate* delegate) OVERRIDE; | 337 PrivetLocalPrintOperation::Delegate* delegate) override; |
338 | 338 |
339 private: | 339 private: |
340 PrivetHTTPClient* info_client() { return info_client_.get(); } | 340 PrivetHTTPClient* info_client() { return info_client_.get(); } |
341 | 341 |
342 scoped_ptr<PrivetHTTPClient> info_client_; | 342 scoped_ptr<PrivetHTTPClient> info_client_; |
343 | 343 |
344 DISALLOW_COPY_AND_ASSIGN(PrivetV1HTTPClientImpl); | 344 DISALLOW_COPY_AND_ASSIGN(PrivetV1HTTPClientImpl); |
345 }; | 345 }; |
346 | 346 |
347 } // namespace local_discovery | 347 } // namespace local_discovery |
348 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 348 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
OLD | NEW |