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

Side by Side Diff: chrome/browser/extensions/webstore_installer.cc

Issue 1475803002: Remove kuint16max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint2
Patch Set: cloud print Created 5 years 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 | « base/basictypes.h ('k') | chrome/browser/sync/test/integration/sync_test.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 "chrome/browser/extensions/webstore_installer.h" 5 #include "chrome/browser/extensions/webstore_installer.h"
6 6
7 #include <stdint.h>
8
9 #include <limits>
7 #include <set> 10 #include <set>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/basictypes.h"
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/command_line.h" 14 #include "base/command_line.h"
13 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
14 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
16 #include "base/metrics/sparse_histogram.h" 18 #include "base/metrics/sparse_histogram.h"
17 #include "base/path_service.h" 19 #include "base/path_service.h"
18 #include "base/rand_util.h" 20 #include "base/rand_util.h"
19 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 116 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
115 base::Bind(callback, base::FilePath())); 117 base::Bind(callback, base::FilePath()));
116 return; 118 return;
117 } 119 }
118 } 120 }
119 121
120 // This is to help avoid a race condition between when we generate this 122 // This is to help avoid a race condition between when we generate this
121 // filename and when the download starts writing to it (think concurrently 123 // filename and when the download starts writing to it (think concurrently
122 // running sharded browser tests installing the same test file, for 124 // running sharded browser tests installing the same test file, for
123 // instance). 125 // instance).
124 std::string random_number = 126 std::string random_number = base::Uint64ToString(
125 base::Uint64ToString(base::RandGenerator(kuint16max)); 127 base::RandGenerator(std::numeric_limits<uint16_t>::max()));
126 128
127 base::FilePath file = 129 base::FilePath file =
128 download_directory.AppendASCII(id + "_" + random_number + ".crx"); 130 download_directory.AppendASCII(id + "_" + random_number + ".crx");
129 131
130 int uniquifier = 132 int uniquifier =
131 base::GetUniquePathNumber(file, base::FilePath::StringType()); 133 base::GetUniquePathNumber(file, base::FilePath::StringType());
132 if (uniquifier > 0) { 134 if (uniquifier > 0) {
133 file = file.InsertBeforeExtensionASCII( 135 file = file.InsertBeforeExtensionASCII(
134 base::StringPrintf(" (%d)", uniquifier)); 136 base::StringPrintf(" (%d)", uniquifier));
135 } 137 }
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 763
762 Release(); // Balanced in Start(). 764 Release(); // Balanced in Start().
763 } 765 }
764 766
765 void WebstoreInstaller::RecordInterrupt(const DownloadItem* download) const { 767 void WebstoreInstaller::RecordInterrupt(const DownloadItem* download) const {
766 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.WebstoreDownload.InterruptReason", 768 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.WebstoreDownload.InterruptReason",
767 download->GetLastReason()); 769 download->GetLastReason());
768 770
769 // Use logarithmic bin sizes up to 1 TB. 771 // Use logarithmic bin sizes up to 1 TB.
770 const int kNumBuckets = 30; 772 const int kNumBuckets = 30;
771 const int64 kMaxSizeKb = 1 << kNumBuckets; 773 const int64_t kMaxSizeKb = 1 << kNumBuckets;
772 UMA_HISTOGRAM_CUSTOM_COUNTS( 774 UMA_HISTOGRAM_CUSTOM_COUNTS(
773 "Extensions.WebstoreDownload.InterruptReceivedKBytes", 775 "Extensions.WebstoreDownload.InterruptReceivedKBytes",
774 download->GetReceivedBytes() / 1024, 776 download->GetReceivedBytes() / 1024,
775 1, 777 1,
776 kMaxSizeKb, 778 kMaxSizeKb,
777 kNumBuckets); 779 kNumBuckets);
778 int64 total_bytes = download->GetTotalBytes(); 780 int64_t total_bytes = download->GetTotalBytes();
779 if (total_bytes >= 0) { 781 if (total_bytes >= 0) {
780 UMA_HISTOGRAM_CUSTOM_COUNTS( 782 UMA_HISTOGRAM_CUSTOM_COUNTS(
781 "Extensions.WebstoreDownload.InterruptTotalKBytes", 783 "Extensions.WebstoreDownload.InterruptTotalKBytes",
782 total_bytes / 1024, 784 total_bytes / 1024,
783 1, 785 1,
784 kMaxSizeKb, 786 kMaxSizeKb,
785 kNumBuckets); 787 kNumBuckets);
786 } 788 }
787 UMA_HISTOGRAM_BOOLEAN( 789 UMA_HISTOGRAM_BOOLEAN(
788 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown", 790 "Extensions.WebstoreDownload.InterruptTotalSizeUnknown",
789 total_bytes <= 0); 791 total_bytes <= 0);
790 } 792 }
791 793
792 } // namespace extensions 794 } // namespace extensions
OLDNEW
« no previous file with comments | « base/basictypes.h ('k') | chrome/browser/sync/test/integration/sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698