Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: google_apis/drive/base_requests.h

Issue 127613002: google_apis: Stop accessing URLFetcher from ResponseWriter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | google_apis/drive/base_requests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(net::URLFetcher* url_fetcher, 97 ResponseWriter(base::SequencedTaskRunner* file_task_runner,
98 base::SequencedTaskRunner* file_task_runner,
99 const base::FilePath& file_path, 98 const base::FilePath& file_path,
100 const GetContentCallback& get_content_callback); 99 const GetContentCallback& get_content_callback);
101 virtual ~ResponseWriter(); 100 virtual ~ResponseWriter();
102 101
103 const std::string& data() const { return data_; } 102 const std::string& data() const { return data_; }
104 103
105 // Disowns the output file. 104 // Disowns the output file.
106 void DisownFile(); 105 void DisownFile();
107 106
108 // URLFetcherResponseWriter overrides: 107 // URLFetcherResponseWriter overrides:
109 virtual int Initialize(const net::CompletionCallback& callback) OVERRIDE; 108 virtual int Initialize(const net::CompletionCallback& callback) OVERRIDE;
110 virtual int Write(net::IOBuffer* buffer, 109 virtual int Write(net::IOBuffer* buffer,
111 int num_bytes, 110 int num_bytes,
112 const net::CompletionCallback& callback) OVERRIDE; 111 const net::CompletionCallback& callback) OVERRIDE;
113 virtual int Finish(const net::CompletionCallback& callback) OVERRIDE; 112 virtual int Finish(const net::CompletionCallback& callback) OVERRIDE;
114 113
115 private: 114 private:
116 net::URLFetcher* url_fetcher_; 115 void DidWrite(scoped_refptr<net::IOBuffer> buffer,
116 const net::CompletionCallback& callback,
117 int result);
118
117 const GetContentCallback get_content_callback_; 119 const GetContentCallback get_content_callback_;
118 std::string data_; 120 std::string data_;
119 scoped_ptr<net::URLFetcherFileWriter> file_writer_; 121 scoped_ptr<net::URLFetcherFileWriter> file_writer_;
122 base::WeakPtrFactory<ResponseWriter> weak_ptr_factory_;
120 123
121 DISALLOW_COPY_AND_ASSIGN(ResponseWriter); 124 DISALLOW_COPY_AND_ASSIGN(ResponseWriter);
122 }; 125 };
123 126
124 //============================ UrlFetchRequestBase =========================== 127 //============================ UrlFetchRequestBase ===========================
125 128
126 // Base class for requests that are fetching URLs. 129 // Base class for requests that are fetching URLs.
127 class UrlFetchRequestBase : public AuthenticatedRequestInterface, 130 class UrlFetchRequestBase : public AuthenticatedRequestInterface,
128 public net::URLFetcherDelegate { 131 public net::URLFetcherDelegate {
129 public: 132 public:
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 const ProgressCallback progress_callback_; 530 const ProgressCallback progress_callback_;
528 const GURL download_url_; 531 const GURL download_url_;
529 const base::FilePath output_file_path_; 532 const base::FilePath output_file_path_;
530 533
531 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); 534 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase);
532 }; 535 };
533 536
534 } // namespace google_apis 537 } // namespace google_apis
535 538
536 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 539 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/drive/base_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698