| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 148 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 class PrivetDataReadOperationImpl : public PrivetDataReadOperation, | 151 class PrivetDataReadOperationImpl : public PrivetDataReadOperation, |
| 152 public PrivetURLFetcher::Delegate { | 152 public PrivetURLFetcher::Delegate { |
| 153 public: | 153 public: |
| 154 PrivetDataReadOperationImpl( | 154 PrivetDataReadOperationImpl( |
| 155 PrivetHTTPClientImpl* privet_client, | 155 PrivetHTTPClientImpl* privet_client, |
| 156 const std::string& path, | 156 const std::string& path, |
| 157 net::URLFetcher::RequestType request_type, |
| 157 const PrivetDataReadOperation::ResultCallback& callback); | 158 const PrivetDataReadOperation::ResultCallback& callback); |
| 158 virtual ~PrivetDataReadOperationImpl(); | 159 virtual ~PrivetDataReadOperationImpl(); |
| 159 | 160 |
| 160 virtual void Start() OVERRIDE; | 161 virtual void Start() OVERRIDE; |
| 161 | 162 |
| 162 virtual void SetDataRange(int range_start, int range_end) OVERRIDE; | 163 virtual void SetDataRange(int range_start, int range_end) OVERRIDE; |
| 163 | 164 |
| 164 virtual void SaveDataToFile() OVERRIDE; | 165 virtual void SaveDataToFile() OVERRIDE; |
| 165 | 166 |
| 167 virtual void SetUploadFile(const base::FilePath& upload_file) OVERRIDE; |
| 168 |
| 166 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; | 169 virtual PrivetHTTPClient* GetHTTPClient() OVERRIDE; |
| 167 | 170 |
| 168 virtual void OnError(PrivetURLFetcher* fetcher, | 171 virtual void OnError(PrivetURLFetcher* fetcher, |
| 169 PrivetURLFetcher::ErrorType error) OVERRIDE; | 172 PrivetURLFetcher::ErrorType error) OVERRIDE; |
| 170 virtual void OnParsedJson(PrivetURLFetcher* fetcher, | 173 virtual void OnParsedJson(PrivetURLFetcher* fetcher, |
| 171 const base::DictionaryValue* value, | 174 const base::DictionaryValue* value, |
| 172 bool has_error) OVERRIDE; | 175 bool has_error) OVERRIDE; |
| 173 virtual void OnNeedPrivetToken( | 176 virtual void OnNeedPrivetToken( |
| 174 PrivetURLFetcher* fetcher, | 177 PrivetURLFetcher* fetcher, |
| 175 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; | 178 const PrivetURLFetcher::TokenCallback& callback) OVERRIDE; |
| 176 virtual bool OnRawData(PrivetURLFetcher* fetcher, | 179 virtual bool OnRawData(PrivetURLFetcher* fetcher, |
| 177 bool is_file, | 180 bool is_file, |
| 178 const std::string& data_str, | 181 const std::string& data_str, |
| 179 const base::FilePath& file_path) OVERRIDE; | 182 const base::FilePath& file_path) OVERRIDE; |
| 180 | 183 |
| 181 void AppendQueryParameter(const std::string& name, const std::string& value); | 184 void AppendQueryParameter(const std::string& name, const std::string& value); |
| 182 | 185 |
| 183 private: | 186 private: |
| 184 PrivetHTTPClientImpl* privet_client_; | 187 PrivetHTTPClientImpl* privet_client_; |
| 185 GURL url_; | 188 GURL url_; |
| 186 int range_start_; | 189 int range_start_; |
| 187 int range_end_; | 190 int range_end_; |
| 191 net::URLFetcher::RequestType request_type_; |
| 188 PrivetDataReadOperation::ResultCallback callback_; | 192 PrivetDataReadOperation::ResultCallback callback_; |
| 189 | 193 |
| 190 bool has_range_; | 194 bool has_range_; |
| 191 bool save_to_file_; | 195 bool save_to_file_; |
| 196 bool has_upload_file_; |
| 197 |
| 198 base::FilePath upload_file_; |
| 192 | 199 |
| 193 scoped_ptr<PrivetURLFetcher> url_fetcher_; | 200 scoped_ptr<PrivetURLFetcher> url_fetcher_; |
| 194 }; | 201 }; |
| 195 | 202 |
| 196 class PrivetLocalPrintOperationImpl | 203 class PrivetLocalPrintOperationImpl |
| 197 : public PrivetLocalPrintOperation, | 204 : public PrivetLocalPrintOperation, |
| 198 public PrivetURLFetcher::Delegate { | 205 public PrivetURLFetcher::Delegate { |
| 199 public: | 206 public: |
| 200 PrivetLocalPrintOperationImpl( | 207 PrivetLocalPrintOperationImpl( |
| 201 PrivetHTTPClientImpl* privet_client, | 208 PrivetHTTPClientImpl* privet_client, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 const std::string& src_path, | 331 const std::string& src_path, |
| 325 const std::string& dest_path, | 332 const std::string& dest_path, |
| 326 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 333 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; |
| 327 | 334 |
| 328 virtual scoped_ptr<PrivetJSONOperation> CreateStorageCreateOperation( | 335 virtual scoped_ptr<PrivetJSONOperation> CreateStorageCreateOperation( |
| 329 const std::string& path, | 336 const std::string& path, |
| 330 const std::string& name, | 337 const std::string& name, |
| 331 bool is_dir, | 338 bool is_dir, |
| 332 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; | 339 const PrivetJSONOperation::ResultCallback& callback) OVERRIDE; |
| 333 | 340 |
| 341 virtual scoped_ptr<PrivetDataReadOperation> CreateStorageOverwriteOperation( |
| 342 const std::string& path, |
| 343 const PrivetDataReadOperation::ResultCallback& callback) OVERRIDE; |
| 344 |
| 334 virtual const std::string& GetName() OVERRIDE; | 345 virtual const std::string& GetName() OVERRIDE; |
| 335 | 346 |
| 336 scoped_ptr<PrivetURLFetcher> CreateURLFetcher( | 347 scoped_ptr<PrivetURLFetcher> CreateURLFetcher( |
| 337 const GURL& url, | 348 const GURL& url, |
| 338 net::URLFetcher::RequestType request_type, | 349 net::URLFetcher::RequestType request_type, |
| 339 PrivetURLFetcher::Delegate* delegate) const; | 350 PrivetURLFetcher::Delegate* delegate) const; |
| 340 | 351 |
| 341 void RefreshPrivetToken( | 352 void RefreshPrivetToken( |
| 342 const PrivetURLFetcher::TokenCallback& token_callback); | 353 const PrivetURLFetcher::TokenCallback& token_callback); |
| 343 | 354 |
| 344 private: | 355 private: |
| 345 typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector; | 356 typedef std::vector<PrivetURLFetcher::TokenCallback> TokenCallbackVector; |
| 346 | 357 |
| 347 void OnPrivetInfoDone(const base::DictionaryValue* value); | 358 void OnPrivetInfoDone(const base::DictionaryValue* value); |
| 348 | 359 |
| 349 std::string name_; | 360 std::string name_; |
| 350 scoped_refptr<net::URLRequestContextGetter> request_context_; | 361 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 351 net::HostPortPair host_port_; | 362 net::HostPortPair host_port_; |
| 352 | 363 |
| 353 scoped_ptr<PrivetJSONOperation> info_operation_; | 364 scoped_ptr<PrivetJSONOperation> info_operation_; |
| 354 TokenCallbackVector token_callbacks_; | 365 TokenCallbackVector token_callbacks_; |
| 355 }; | 366 }; |
| 356 | 367 |
| 357 } // namespace local_discovery | 368 } // namespace local_discovery |
| 358 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ | 369 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_IMPL_H_ |
| OLD | NEW |