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

Side by Side Diff: net/url_request/test_url_fetcher_factory.h

Issue 11843003: Add SetUploadDataStream method to URLFetcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & updated for UploadFileElementReader changes Created 7 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
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 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 5 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Callback issued correspondingly to the destructor. 74 // Callback issued correspondingly to the destructor.
75 virtual void OnRequestEnd(int fetcher_id) = 0; 75 virtual void OnRequestEnd(int fetcher_id) = 0;
76 }; 76 };
77 77
78 TestURLFetcher(int id, 78 TestURLFetcher(int id,
79 const GURL& url, 79 const GURL& url,
80 URLFetcherDelegate* d); 80 URLFetcherDelegate* d);
81 virtual ~TestURLFetcher(); 81 virtual ~TestURLFetcher();
82 82
83 // URLFetcher implementation 83 // URLFetcher implementation
84 virtual void SetUploadDataStream(
85 const std::string& upload_content_type,
86 scoped_ptr<UploadDataStream> upload_content) OVERRIDE;
84 virtual void SetUploadData(const std::string& upload_content_type, 87 virtual void SetUploadData(const std::string& upload_content_type,
85 const std::string& upload_content) OVERRIDE; 88 const std::string& upload_content) OVERRIDE;
86 virtual void SetChunkedUpload( 89 virtual void SetChunkedUpload(
87 const std::string& upload_content_type) OVERRIDE; 90 const std::string& upload_content_type) OVERRIDE;
88 // Overriden to cache the chunks uploaded. Caller can read back the uploaded 91 // Overriden to cache the chunks uploaded. Caller can read back the uploaded
89 // chunks with the upload_chunks() accessor. 92 // chunks with the upload_chunks() accessor.
90 virtual void AppendChunkToUpload(const std::string& data, 93 virtual void AppendChunkToUpload(const std::string& data,
91 bool is_last_chunk) OVERRIDE; 94 bool is_last_chunk) OVERRIDE;
92 virtual void SetLoadFlags(int load_flags) OVERRIDE; 95 virtual void SetLoadFlags(int load_flags) OVERRIDE;
93 virtual int GetLoadFlags() const OVERRIDE; 96 virtual int GetLoadFlags() const OVERRIDE;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool take_ownership, FilePath* out_response_path) const OVERRIDE; 141 bool take_ownership, FilePath* out_response_path) const OVERRIDE;
139 142
140 // Sets owner of this class. Set it to a non-NULL value if you want 143 // Sets owner of this class. Set it to a non-NULL value if you want
141 // to automatically unregister this fetcher from the owning factory 144 // to automatically unregister this fetcher from the owning factory
142 // upon destruction. 145 // upon destruction.
143 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; } 146 void set_owner(TestURLFetcherFactory* owner) { owner_ = owner; }
144 147
145 // Unique ID in our factory. 148 // Unique ID in our factory.
146 int id() const { return id_; } 149 int id() const { return id_; }
147 150
151 // Returns the data stream uploaded on this URLFetcher.
152 const UploadDataStream* upload_data_stream() const {
153 return upload_data_stream_.get();
154 }
155
148 // Returns the data uploaded on this URLFetcher. 156 // Returns the data uploaded on this URLFetcher.
149 const std::string& upload_data() const { return upload_data_; } 157 const std::string& upload_data() const { return upload_data_; }
150 158
151 // Returns the chunks of data uploaded on this URLFetcher. 159 // Returns the chunks of data uploaded on this URLFetcher.
152 const std::list<std::string>& upload_chunks() const { return chunks_; } 160 const std::list<std::string>& upload_chunks() const { return chunks_; }
153 161
154 // Checks whether the last call to |AppendChunkToUpload(...)| was final. 162 // Checks whether the last call to |AppendChunkToUpload(...)| was final.
155 bool did_receive_last_chunk() const { return did_receive_last_chunk_; } 163 bool did_receive_last_chunk() const { return did_receive_last_chunk_; }
156 164
157 // Returns the delegate installed on the URLFetcher. 165 // Returns the delegate installed on the URLFetcher.
(...skipping 21 matching lines...) Expand all
179 STRING, // Default: In a std::string 187 STRING, // Default: In a std::string
180 TEMP_FILE // Write to a temp file 188 TEMP_FILE // Write to a temp file
181 }; 189 };
182 190
183 TestURLFetcherFactory* owner_; 191 TestURLFetcherFactory* owner_;
184 const int id_; 192 const int id_;
185 const GURL original_url_; 193 const GURL original_url_;
186 URLFetcherDelegate* delegate_; 194 URLFetcherDelegate* delegate_;
187 DelegateForTests* delegate_for_tests_; 195 DelegateForTests* delegate_for_tests_;
188 std::string upload_data_; 196 std::string upload_data_;
197 scoped_ptr<UploadDataStream> upload_data_stream_;
189 std::list<std::string> chunks_; 198 std::list<std::string> chunks_;
190 bool did_receive_last_chunk_; 199 bool did_receive_last_chunk_;
191 200
192 // User can use set_* methods to provide values returned by getters. 201 // User can use set_* methods to provide values returned by getters.
193 // Setting the real values is not possible, because the real class 202 // Setting the real values is not possible, because the real class
194 // has no setters. The data is a private member of a class defined 203 // has no setters. The data is a private member of a class defined
195 // in a .cc file, so we can't get at it with friendship. 204 // in a .cc file, so we can't get at it with friendship.
196 int fake_load_flags_; 205 int fake_load_flags_;
197 GURL fake_url_; 206 GURL fake_url_;
198 URLRequestStatus fake_status_; 207 URLRequestStatus fake_status_;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 int id, 339 int id,
331 const GURL& url, 340 const GURL& url,
332 URLFetcher::RequestType request_type, 341 URLFetcher::RequestType request_type,
333 URLFetcherDelegate* d) OVERRIDE; 342 URLFetcherDelegate* d) OVERRIDE;
334 343
335 }; 344 };
336 345
337 } // namespace net 346 } // namespace net
338 347
339 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ 348 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « no previous file | net/url_request/test_url_fetcher_factory.cc » ('j') | net/url_request/test_url_fetcher_factory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698