| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file provides base classes used to issue HTTP requests for Google | 5 // This file provides base classes used to issue HTTP requests for Google |
| 6 // APIs. | 6 // APIs. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ | 8 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ |
| 9 #define CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ | 9 #define CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 virtual void Cancel() = 0; | 87 virtual void Cancel() = 0; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 //=========================== ResponseWriter ================================== | 90 //=========================== ResponseWriter ================================== |
| 91 | 91 |
| 92 // Saves the response for the request to a file or string. | 92 // Saves the response for the request to a file or string. |
| 93 class ResponseWriter : public net::URLFetcherResponseWriter { | 93 class ResponseWriter : public net::URLFetcherResponseWriter { |
| 94 public: | 94 public: |
| 95 // If file_path is not empty, the response will be saved with file_writer_, | 95 // If file_path is not empty, the response will be saved with file_writer_, |
| 96 // otherwise it will be saved to data_. | 96 // otherwise it will be saved to data_. |
| 97 ResponseWriter(base::TaskRunner* file_task_runner, | 97 ResponseWriter(base::SequencedTaskRunner* file_task_runner, |
| 98 const base::FilePath& file_path, | 98 const base::FilePath& file_path, |
| 99 const GetContentCallback& get_content_callback); | 99 const GetContentCallback& get_content_callback); |
| 100 virtual ~ResponseWriter(); | 100 virtual ~ResponseWriter(); |
| 101 | 101 |
| 102 const std::string& data() const { return data_; } | 102 const std::string& data() const { return data_; } |
| 103 | 103 |
| 104 // Disowns the output file. | 104 // Disowns the output file. |
| 105 void DisownFile(); | 105 void DisownFile(); |
| 106 | 106 |
| 107 // URLFetcherResponseWriter overrides: | 107 // URLFetcherResponseWriter overrides: |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // the status of the URLFetcher. | 186 // the status of the URLFetcher. |
| 187 static GDataErrorCode GetErrorCode(const net::URLFetcher* source); | 187 static GDataErrorCode GetErrorCode(const net::URLFetcher* source); |
| 188 | 188 |
| 189 // Returns true if called on the thread where the constructor was called. | 189 // Returns true if called on the thread where the constructor was called. |
| 190 bool CalledOnValidThread(); | 190 bool CalledOnValidThread(); |
| 191 | 191 |
| 192 // Returns the writer which is used to save the response for the request. | 192 // Returns the writer which is used to save the response for the request. |
| 193 ResponseWriter* response_writer() const { return response_writer_; } | 193 ResponseWriter* response_writer() const { return response_writer_; } |
| 194 | 194 |
| 195 // Returns the task runner that should be used for blocking tasks. | 195 // Returns the task runner that should be used for blocking tasks. |
| 196 base::TaskRunner* blocking_task_runner() const; | 196 base::SequencedTaskRunner* blocking_task_runner() const; |
| 197 | 197 |
| 198 private: | 198 private: |
| 199 // URLFetcherDelegate overrides. | 199 // URLFetcherDelegate overrides. |
| 200 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 200 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 201 | 201 |
| 202 // AuthenticatedRequestInterface overrides. | 202 // AuthenticatedRequestInterface overrides. |
| 203 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE; | 203 virtual void OnAuthFailed(GDataErrorCode code) OVERRIDE; |
| 204 | 204 |
| 205 ReAuthenticateCallback re_authenticate_callback_; | 205 ReAuthenticateCallback re_authenticate_callback_; |
| 206 int re_authenticate_count_; | 206 int re_authenticate_count_; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 const ProgressCallback progress_callback_; | 524 const ProgressCallback progress_callback_; |
| 525 const GURL download_url_; | 525 const GURL download_url_; |
| 526 const base::FilePath output_file_path_; | 526 const base::FilePath output_file_path_; |
| 527 | 527 |
| 528 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); | 528 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); |
| 529 }; | 529 }; |
| 530 | 530 |
| 531 } // namespace google_apis | 531 } // namespace google_apis |
| 532 | 532 |
| 533 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ | 533 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_REQUESTS_H_ |
| OLD | NEW |