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

Side by Side Diff: extensions/browser/sandboxed_unpacker.cc

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 4 years, 12 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
« no previous file with comments | « extensions/browser/sandboxed_unpacker.h ('k') | extensions/browser/script_executor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/browser/sandboxed_unpacker.h" 5 #include "extensions/browser/sandboxed_unpacker.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <set> 10 #include <set>
8 11
9 #include "base/bind.h" 12 #include "base/bind.h"
10 #include "base/command_line.h" 13 #include "base/command_line.h"
11 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
12 #include "base/json/json_string_value_serializer.h" 15 #include "base/json/json_string_value_serializer.h"
13 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
15 #include "base/numerics/safe_conversions.h" 18 #include "base/numerics/safe_conversions.h"
16 #include "base/path_service.h" 19 #include "base/path_service.h"
17 #include "base/sequenced_task_runner.h" 20 #include "base/sequenced_task_runner.h"
18 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
20 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
24 #include "build/build_config.h"
21 #include "components/crx_file/crx_file.h" 25 #include "components/crx_file/crx_file.h"
22 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/utility_process_host.h" 27 #include "content/public/browser/utility_process_host.h"
24 #include "content/public/common/common_param_traits.h" 28 #include "content/public/common/common_param_traits.h"
25 #include "extensions/common/constants.h" 29 #include "extensions/common/constants.h"
26 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
27 #include "extensions/common/extension_l10n_util.h" 31 #include "extensions/common/extension_l10n_util.h"
28 #include "extensions/common/extension_utility_messages.h" 32 #include "extensions/common/extension_utility_messages.h"
29 #include "extensions/common/extensions_client.h" 33 #include "extensions/common/extensions_client.h"
30 #include "extensions/common/file_util.h" 34 #include "extensions/common/file_util.h"
(...skipping 22 matching lines...) Expand all
53 // Record a rate (kB per second) at which extensions are unpacked. 57 // Record a rate (kB per second) at which extensions are unpacked.
54 // Range from 1kB/s to 100mB/s. 58 // Range from 1kB/s to 100mB/s.
55 #define UNPACK_RATE_HISTOGRAM(name, rate) \ 59 #define UNPACK_RATE_HISTOGRAM(name, rate) \
56 UMA_HISTOGRAM_CUSTOM_COUNTS(name, rate, 1, 100000, 100); 60 UMA_HISTOGRAM_CUSTOM_COUNTS(name, rate, 1, 100000, 100);
57 61
58 namespace extensions { 62 namespace extensions {
59 namespace { 63 namespace {
60 64
61 void RecordSuccessfulUnpackTimeHistograms(const base::FilePath& crx_path, 65 void RecordSuccessfulUnpackTimeHistograms(const base::FilePath& crx_path,
62 const base::TimeDelta unpack_time) { 66 const base::TimeDelta unpack_time) {
63 const int64 kBytesPerKb = 1024; 67 const int64_t kBytesPerKb = 1024;
64 const int64 kBytesPerMb = 1024 * 1024; 68 const int64_t kBytesPerMb = 1024 * 1024;
65 69
66 UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackSuccessTime", unpack_time); 70 UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackSuccessTime", unpack_time);
67 71
68 // To get a sense of how CRX size impacts unpack time, record unpack 72 // To get a sense of how CRX size impacts unpack time, record unpack
69 // time for several increments of CRX size. 73 // time for several increments of CRX size.
70 int64 crx_file_size; 74 int64_t crx_file_size;
71 if (!base::GetFileSize(crx_path, &crx_file_size)) { 75 if (!base::GetFileSize(crx_path, &crx_file_size)) {
72 UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccessCantGetCrxSize", 1); 76 UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccessCantGetCrxSize", 1);
73 return; 77 return;
74 } 78 }
75 79
76 // Cast is safe as long as the number of bytes in the CRX is less than 80 // Cast is safe as long as the number of bytes in the CRX is less than
77 // 2^31 * 2^10. 81 // 2^31 * 2^10.
78 int crx_file_size_kb = static_cast<int>(crx_file_size / kBytesPerKb); 82 int crx_file_size_kb = static_cast<int>(crx_file_size / kBytesPerKb);
79 UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccessCrxSize", 83 UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccessCrxSize",
80 crx_file_size_kb); 84 crx_file_size_kb);
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 924
921 SandboxedUnpacker::UtilityHostWrapper::~UtilityHostWrapper() { 925 SandboxedUnpacker::UtilityHostWrapper::~UtilityHostWrapper() {
922 DCHECK_CURRENTLY_ON(BrowserThread::IO); 926 DCHECK_CURRENTLY_ON(BrowserThread::IO);
923 if (utility_host_) { 927 if (utility_host_) {
924 utility_host_->EndBatchMode(); 928 utility_host_->EndBatchMode();
925 utility_host_.reset(); 929 utility_host_.reset();
926 } 930 }
927 } 931 }
928 932
929 } // namespace extensions 933 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/sandboxed_unpacker.h ('k') | extensions/browser/script_executor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698