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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <algorithm> | 10 #include <algorithm> |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/base64.h" | 14 #include "base/base64.h" |
12 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
15 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
16 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
18 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
19 #include "base/metrics/field_trial.h" | 23 #include "base/metrics/field_trial.h" |
20 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
21 #include "base/metrics/sparse_histogram.h" | 25 #include "base/metrics/sparse_histogram.h" |
22 #include "base/sha1.h" | 26 #include "base/sha1.h" |
23 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_util.h" | 28 #include "base/strings/string_util.h" |
25 #include "base/strings/stringprintf.h" | 29 #include "base/strings/stringprintf.h" |
26 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 base::FilePath* file_path, | 140 base::FilePath* file_path, |
137 base::Time* last_modified_time) { | 141 base::Time* last_modified_time) { |
138 *file_path = resource.GetFilePath(); | 142 *file_path = resource.GetFilePath(); |
139 *last_modified_time = GetFileLastModifiedTime(*file_path); | 143 *last_modified_time = GetFileLastModifiedTime(*file_path); |
140 // While we're here, log the delta between extension directory | 144 // While we're here, log the delta between extension directory |
141 // creation time and the resource's last modification time. | 145 // creation time and the resource's last modification time. |
142 base::ElapsedTimer query_timer; | 146 base::ElapsedTimer query_timer; |
143 base::Time dir_creation_time = GetFileCreationTime(directory); | 147 base::Time dir_creation_time = GetFileCreationTime(directory); |
144 UMA_HISTOGRAM_TIMES("Extensions.ResourceDirectoryTimestampQueryLatency", | 148 UMA_HISTOGRAM_TIMES("Extensions.ResourceDirectoryTimestampQueryLatency", |
145 query_timer.Elapsed()); | 149 query_timer.Elapsed()); |
146 int64 delta_seconds = (*last_modified_time - dir_creation_time).InSeconds(); | 150 int64_t delta_seconds = (*last_modified_time - dir_creation_time).InSeconds(); |
147 if (delta_seconds >= 0) { | 151 if (delta_seconds >= 0) { |
148 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ResourceLastModifiedDelta", | 152 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ResourceLastModifiedDelta", |
149 delta_seconds, | 153 delta_seconds, |
150 0, | 154 0, |
151 base::TimeDelta::FromDays(30).InSeconds(), | 155 base::TimeDelta::FromDays(30).InSeconds(), |
152 50); | 156 50); |
153 } else { | 157 } else { |
154 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ResourceLastModifiedNegativeDelta", | 158 UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ResourceLastModifiedNegativeDelta", |
155 -delta_seconds, | 159 -delta_seconds, |
156 1, | 160 1, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // TODO(asargent) - we'll need to add proper support for range headers. | 229 // TODO(asargent) - we'll need to add proper support for range headers. |
226 // crbug.com/369895. | 230 // crbug.com/369895. |
227 std::string range_header; | 231 std::string range_header; |
228 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { | 232 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { |
229 if (verify_job_.get()) | 233 if (verify_job_.get()) |
230 verify_job_ = NULL; | 234 verify_job_ = NULL; |
231 } | 235 } |
232 URLRequestFileJob::SetExtraRequestHeaders(headers); | 236 URLRequestFileJob::SetExtraRequestHeaders(headers); |
233 } | 237 } |
234 | 238 |
235 void OnSeekComplete(int64 result) override { | 239 void OnSeekComplete(int64_t result) override { |
236 DCHECK_EQ(seek_position_, 0); | 240 DCHECK_EQ(seek_position_, 0); |
237 seek_position_ = result; | 241 seek_position_ = result; |
238 // TODO(asargent) - we'll need to add proper support for range headers. | 242 // TODO(asargent) - we'll need to add proper support for range headers. |
239 // crbug.com/369895. | 243 // crbug.com/369895. |
240 if (result > 0 && verify_job_.get()) | 244 if (result > 0 && verify_job_.get()) |
241 verify_job_ = NULL; | 245 verify_job_ = NULL; |
242 } | 246 } |
243 | 247 |
244 void OnReadComplete(net::IOBuffer* buffer, int result) override { | 248 void OnReadComplete(net::IOBuffer* buffer, int result) override { |
245 if (result >= 0) | 249 if (result >= 0) |
(...skipping 28 matching lines...) Expand all Loading... |
274 send_cors_header_, | 278 send_cors_header_, |
275 *last_modified_time); | 279 *last_modified_time); |
276 URLRequestFileJob::Start(); | 280 URLRequestFileJob::Start(); |
277 } | 281 } |
278 | 282 |
279 scoped_refptr<ContentVerifyJob> verify_job_; | 283 scoped_refptr<ContentVerifyJob> verify_job_; |
280 | 284 |
281 scoped_ptr<base::ElapsedTimer> request_timer_; | 285 scoped_ptr<base::ElapsedTimer> request_timer_; |
282 | 286 |
283 // The position we seeked to in the file. | 287 // The position we seeked to in the file. |
284 int64 seek_position_; | 288 int64_t seek_position_; |
285 | 289 |
286 // The number of bytes of content we read from the file. | 290 // The number of bytes of content we read from the file. |
287 int bytes_read_; | 291 int bytes_read_; |
288 | 292 |
289 net::HttpResponseInfo response_info_; | 293 net::HttpResponseInfo response_info_; |
290 base::FilePath directory_path_; | 294 base::FilePath directory_path_; |
291 extensions::ExtensionResource resource_; | 295 extensions::ExtensionResource resource_; |
292 std::string content_security_policy_; | 296 std::string content_security_policy_; |
293 bool send_cors_header_; | 297 bool send_cors_header_; |
294 base::WeakPtrFactory<URLRequestExtensionJob> weak_factory_; | 298 base::WeakPtrFactory<URLRequestExtensionJob> weak_factory_; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 562 } |
559 | 563 |
560 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 564 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
561 CreateExtensionProtocolHandler(bool is_incognito, | 565 CreateExtensionProtocolHandler(bool is_incognito, |
562 extensions::InfoMap* extension_info_map) { | 566 extensions::InfoMap* extension_info_map) { |
563 return make_scoped_ptr( | 567 return make_scoped_ptr( |
564 new ExtensionProtocolHandler(is_incognito, extension_info_map)); | 568 new ExtensionProtocolHandler(is_incognito, extension_info_map)); |
565 } | 569 } |
566 | 570 |
567 } // namespace extensions | 571 } // namespace extensions |
OLD | NEW |