| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/net/url_fetcher_impl.h" | 5 #include "content/common/net/url_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 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/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util_proxy.h" | 12 #include "base/file_util_proxy.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop_proxy.h" | 16 #include "base/message_loop_proxy.h" |
| 17 #include "base/metrics/histogram.h" |
| 17 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
| 18 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 21 #include "content/public/common/url_fetcher_delegate.h" | 22 #include "content/public/common/url_fetcher_delegate.h" |
| 22 #include "content/public/common/url_fetcher_factory.h" | 23 #include "content/public/common/url_fetcher_factory.h" |
| 23 #include "googleurl/src/gurl.h" | 24 #include "googleurl/src/gurl.h" |
| 24 #include "net/base/host_port_pair.h" | 25 #include "net/base/host_port_pair.h" |
| 25 #include "net/base/io_buffer.h" | 26 #include "net/base/io_buffer.h" |
| 26 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 void URLFetcherImpl::ReceivedContentWasMalformed() { | 1060 void URLFetcherImpl::ReceivedContentWasMalformed() { |
| 1060 core_->ReceivedContentWasMalformed(); | 1061 core_->ReceivedContentWasMalformed(); |
| 1061 } | 1062 } |
| 1062 | 1063 |
| 1063 bool URLFetcherImpl::GetResponseAsString( | 1064 bool URLFetcherImpl::GetResponseAsString( |
| 1064 std::string* out_response_string) const { | 1065 std::string* out_response_string) const { |
| 1065 if (core_->response_destination_ != STRING) | 1066 if (core_->response_destination_ != STRING) |
| 1066 return false; | 1067 return false; |
| 1067 | 1068 |
| 1068 *out_response_string = core_->data_; | 1069 *out_response_string = core_->data_; |
| 1070 UMA_HISTOGRAM_MEMORY_KB("UrlFetcher.StringResponseSize", |
| 1071 (core_->data_.length() / 1024)); |
| 1072 |
| 1069 return true; | 1073 return true; |
| 1070 } | 1074 } |
| 1071 | 1075 |
| 1072 bool URLFetcherImpl::GetResponseAsFilePath(bool take_ownership, | 1076 bool URLFetcherImpl::GetResponseAsFilePath(bool take_ownership, |
| 1073 FilePath* out_response_path) const { | 1077 FilePath* out_response_path) const { |
| 1074 DCHECK(core_->delegate_loop_proxy_->BelongsToCurrentThread()); | 1078 DCHECK(core_->delegate_loop_proxy_->BelongsToCurrentThread()); |
| 1075 if (core_->response_destination_ != TEMP_FILE || | 1079 if (core_->response_destination_ != TEMP_FILE || |
| 1076 !core_->temp_file_writer_.get()) | 1080 !core_->temp_file_writer_.get()) |
| 1077 return false; | 1081 return false; |
| 1078 | 1082 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1101 | 1105 |
| 1102 // static | 1106 // static |
| 1103 content::URLFetcherFactory* URLFetcherImpl::factory() { | 1107 content::URLFetcherFactory* URLFetcherImpl::factory() { |
| 1104 return g_factory; | 1108 return g_factory; |
| 1105 } | 1109 } |
| 1106 | 1110 |
| 1107 // static | 1111 // static |
| 1108 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { | 1112 void URLFetcherImpl::set_factory(content::URLFetcherFactory* factory) { |
| 1109 g_factory = factory; | 1113 g_factory = factory; |
| 1110 } | 1114 } |
| OLD | NEW |