| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_protocols.h" | 5 #include "extensions/browser/extension_protocols.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/metrics/sparse_histogram.h" |
| 21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 22 #include "base/sha1.h" | 23 #include "base/sha1.h" |
| 23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/sequenced_worker_pool.h" | 28 #include "base/threading/sequenced_worker_pool.h" |
| 28 #include "base/threading/thread_restrictions.h" | 29 #include "base/threading/thread_restrictions.h" |
| 29 #include "base/timer/elapsed_timer.h" | 30 #include "base/timer/elapsed_timer.h" |
| 30 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 base::Owned(last_modified_time))); | 213 base::Owned(last_modified_time))); |
| 213 DCHECK(posted); | 214 DCHECK(posted); |
| 214 } | 215 } |
| 215 | 216 |
| 216 virtual void OnSeekComplete(int64 result) OVERRIDE { | 217 virtual void OnSeekComplete(int64 result) OVERRIDE { |
| 217 DCHECK_EQ(seek_position_, 0); | 218 DCHECK_EQ(seek_position_, 0); |
| 218 seek_position_ = result; | 219 seek_position_ = result; |
| 219 } | 220 } |
| 220 | 221 |
| 221 virtual void OnReadComplete(net::IOBuffer* buffer, int result) OVERRIDE { | 222 virtual void OnReadComplete(net::IOBuffer* buffer, int result) OVERRIDE { |
| 222 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.OnReadCompleteResult", result); | 223 if (result >= 0) |
| 224 UMA_HISTOGRAM_COUNTS("ExtensionUrlRequest.OnReadCompleteResult", result); |
| 225 else |
| 226 UMA_HISTOGRAM_SPARSE_SLOWLY("ExtensionUrlRequest.OnReadCompleteError", |
| 227 -result); |
| 223 if (result > 0) { | 228 if (result > 0) { |
| 224 bytes_read_ += result; | 229 bytes_read_ += result; |
| 225 if (hash_.get()) { | 230 if (hash_.get()) { |
| 226 base::ElapsedTimer timer; | 231 base::ElapsedTimer timer; |
| 227 hash_->Update(buffer->data(), result); | 232 hash_->Update(buffer->data(), result); |
| 228 hashing_time_ += timer.Elapsed(); | 233 hashing_time_ += timer.Elapsed(); |
| 229 } | 234 } |
| 230 } | 235 } |
| 231 } | 236 } |
| 232 | 237 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return new net::HttpResponseHeaders(raw_headers); | 543 return new net::HttpResponseHeaders(raw_headers); |
| 539 } | 544 } |
| 540 | 545 |
| 541 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( | 546 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( |
| 542 bool is_incognito, | 547 bool is_incognito, |
| 543 extensions::InfoMap* extension_info_map) { | 548 extensions::InfoMap* extension_info_map) { |
| 544 return new ExtensionProtocolHandler(is_incognito, extension_info_map); | 549 return new ExtensionProtocolHandler(is_incognito, extension_info_map); |
| 545 } | 550 } |
| 546 | 551 |
| 547 } // namespace extensions | 552 } // namespace extensions |
| OLD | NEW |