| Index: chrome/common/net/url_fetcher.cc
|
| ===================================================================
|
| --- chrome/common/net/url_fetcher.cc (revision 86344)
|
| +++ chrome/common/net/url_fetcher.cc (working copy)
|
| @@ -192,7 +192,7 @@
|
| void AppendChunkToUpload(const std::string& data, bool is_last_chunk);
|
|
|
| // Store the response bytes in |buffer_| in the container indicated by
|
| - // |response_destination_|. Return true if the write has been
|
| + // |fetcher_->response_destination_|. Return true if the write has been
|
| // done, and another read can overwrite |buffer_|. If this function
|
| // returns false, it will post a task that will read more bytes once the
|
| // write is complete.
|
| @@ -265,9 +265,6 @@
|
| // writing, and destruction of that file.
|
| scoped_ptr<TempFileWriter> temp_file_writer_;
|
|
|
| - // Where should responses be saved?
|
| - ResponseDestinationType response_destination_;
|
| -
|
| static base::LazyInstance<Registry> g_registry;
|
|
|
| friend class URLFetcher;
|
| @@ -469,6 +466,8 @@
|
| // parameter list to OnURLFetchComplete(). If a user asked to save
|
| // the response to a file, they must use the new parameter list,
|
| // in which case we can not get here.
|
| + CHECK(source->response_destination_ == STRING);
|
| +
|
| // To avoid updating all callers, thunk to the old prototype for now.
|
| OnURLFetchComplete(source,
|
| source->url(),
|
| @@ -487,7 +486,8 @@
|
| : ALLOW_THIS_IN_INITIALIZER_LIST(
|
| core_(new Core(this, url, request_type, d))),
|
| automatically_retry_on_5xx_(true),
|
| - max_retries_(0) {
|
| + max_retries_(0),
|
| + response_destination_(STRING) {
|
| }
|
|
|
| URLFetcher::~URLFetcher() {
|
| @@ -517,8 +517,7 @@
|
| buffer_(new net::IOBuffer(kBufferSize)),
|
| is_chunked_upload_(false),
|
| num_retries_(0),
|
| - was_cancelled_(false),
|
| - response_destination_(STRING) {
|
| + was_cancelled_(false) {
|
| }
|
|
|
| URLFetcher::Core::~Core() {
|
| @@ -533,7 +532,7 @@
|
| io_message_loop_proxy_ = request_context_getter_->GetIOMessageLoopProxy();
|
| CHECK(io_message_loop_proxy_.get()) << "We need an IO message loop proxy";
|
|
|
| - switch (response_destination_) {
|
| + switch (fetcher_->response_destination_) {
|
| case STRING:
|
| io_message_loop_proxy_->PostTask(
|
| FROM_HERE,
|
| @@ -615,7 +614,7 @@
|
| // be done later.
|
| bool URLFetcher::Core::WriteBuffer(int num_bytes) {
|
| bool write_complete = false;
|
| - switch (response_destination_) {
|
| + switch (fetcher_->response_destination_) {
|
| case STRING:
|
| data_.append(buffer_->data(), num_bytes);
|
| write_complete = true;
|
| @@ -914,7 +913,7 @@
|
| void URLFetcher::SaveResponseToTemporaryFile(
|
| scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) {
|
| core_->file_message_loop_proxy_ = file_message_loop_proxy;
|
| - core_->response_destination_ = TEMP_FILE;
|
| + response_destination_ = TEMP_FILE;
|
| }
|
|
|
| net::HttpResponseHeaders* URLFetcher::response_headers() const {
|
| @@ -973,7 +972,7 @@
|
| }
|
|
|
| bool URLFetcher::GetResponseAsString(std::string* out_response_string) const {
|
| - if (core_->response_destination_ != STRING)
|
| + if (response_destination_ != STRING)
|
| return false;
|
|
|
| *out_response_string = core_->data_;
|
| @@ -981,24 +980,13 @@
|
| }
|
|
|
| const std::string& URLFetcher::GetResponseStringRef() const {
|
| - CHECK(core_->response_destination_ == STRING);
|
| + CHECK(response_destination_ == STRING);
|
| return core_->data_;
|
| }
|
|
|
| -void URLFetcher::SetResponseDestinationForTesting(
|
| - ResponseDestinationType value) {
|
| - core_->response_destination_ = value;
|
| -}
|
| -
|
| -URLFetcher::ResponseDestinationType
|
| -URLFetcher::GetResponseDestinationForTesting() const {
|
| - return core_->response_destination_;
|
| -}
|
| -
|
| bool URLFetcher::GetResponseAsFilePath(bool take_ownership,
|
| FilePath* out_response_path) const {
|
| - if (core_->response_destination_ != TEMP_FILE ||
|
| - !core_->temp_file_writer_.get())
|
| + if (response_destination_ != TEMP_FILE || !core_->temp_file_writer_.get())
|
| return false;
|
|
|
| *out_response_path = core_->temp_file_writer_->temp_file();
|
|
|