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

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

Issue 151133002: libaddressinput - one less copy when downloading data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-up Created 6 years, 10 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 #include "net/url_request/test_url_fetcher_factory.h" 5 #include "net/url_request/test_url_fetcher_factory.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
14 #include "net/base/io_buffer.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
16 #include "net/url_request/url_fetcher_delegate.h" 17 #include "net/url_request/url_fetcher_delegate.h"
17 #include "net/url_request/url_fetcher_impl.h" 18 #include "net/url_request/url_fetcher_impl.h"
18 #include "net/url_request/url_fetcher_response_writer.h" 19 #include "net/url_request/url_fetcher_response_writer.h"
19 #include "net/url_request/url_request_status.h" 20 #include "net/url_request/url_request_status.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 ScopedURLFetcherFactory::ScopedURLFetcherFactory( 24 ScopedURLFetcherFactory::ScopedURLFetcherFactory(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 const base::FilePath& file_path, 149 const base::FilePath& file_path,
149 scoped_refptr<base::SequencedTaskRunner> file_task_runner) { 150 scoped_refptr<base::SequencedTaskRunner> file_task_runner) {
150 } 151 }
151 152
152 void TestURLFetcher::SaveResponseToTemporaryFile( 153 void TestURLFetcher::SaveResponseToTemporaryFile(
153 scoped_refptr<base::SequencedTaskRunner> file_task_runner) { 154 scoped_refptr<base::SequencedTaskRunner> file_task_runner) {
154 } 155 }
155 156
156 void TestURLFetcher::SaveResponseWithWriter( 157 void TestURLFetcher::SaveResponseWithWriter(
157 scoped_ptr<URLFetcherResponseWriter> response_writer) { 158 scoped_ptr<URLFetcherResponseWriter> response_writer) {
159 if (fake_response_destination_ == STRING) {
160 response_writer_ = response_writer.Pass();
161 int response = response_writer_->Initialize(CompletionCallback());
162 // The TestURLFetcher doesn't handle asynchronous writes.
163 DCHECK_EQ(OK, response);
164
165 scoped_refptr<IOBuffer> buffer(new StringIOBuffer(fake_response_string_));
166 response = response_writer_->Write(buffer.get(),
167 fake_response_string_.size(),
168 CompletionCallback());
169 DCHECK_EQ(OK, response);
170 response = response_writer_->Finish(CompletionCallback());
171 DCHECK_EQ(OK, response);
172 } else {
173 NOTIMPLEMENTED();
174 }
158 } 175 }
159 176
160 HttpResponseHeaders* TestURLFetcher::GetResponseHeaders() const { 177 HttpResponseHeaders* TestURLFetcher::GetResponseHeaders() const {
161 return fake_response_headers_.get(); 178 return fake_response_headers_.get();
162 } 179 }
163 180
164 HostPortPair TestURLFetcher::GetSocketAddress() const { 181 HostPortPair TestURLFetcher::GetSocketAddress() const {
165 NOTIMPLEMENTED(); 182 NOTIMPLEMENTED();
166 return HostPortPair(); 183 return HostPortPair();
167 } 184 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 418
402 URLFetcher* URLFetcherImplFactory::CreateURLFetcher( 419 URLFetcher* URLFetcherImplFactory::CreateURLFetcher(
403 int id, 420 int id,
404 const GURL& url, 421 const GURL& url,
405 URLFetcher::RequestType request_type, 422 URLFetcher::RequestType request_type,
406 URLFetcherDelegate* d) { 423 URLFetcherDelegate* d) {
407 return new URLFetcherImpl(url, request_type, d); 424 return new URLFetcherImpl(url, request_type, d);
408 } 425 }
409 426
410 } // namespace net 427 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/test_url_fetcher_factory.h ('k') | third_party/libaddressinput/chromium/chrome_downloader_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698