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

Unified Diff: chrome/browser/tracing/crash_service_uploader.cc

Issue 2085623005: Limit the background trials upload size to 100Kib when using mobile data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Configure size limit. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tracing/crash_service_uploader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tracing/crash_service_uploader.cc
diff --git a/chrome/browser/tracing/crash_service_uploader.cc b/chrome/browser/tracing/crash_service_uploader.cc
index b641d5ef247c9dfd8dee2e96a92804c6e5df9532..ab677e509b3c73d42322470c82438686b91f5134 100644
--- a/chrome/browser/tracing/crash_service_uploader.cc
+++ b/chrome/browser/tracing/crash_service_uploader.cc
@@ -43,13 +43,13 @@ const char kMultipartBoundary[] =
const int kHttpResponseOk = 200;
// Allow up to 10MB for trace upload
-const int kMaxUploadBytes = 10000000;
+const size_t kMaxUploadBytes = 10000000;
} // namespace
TraceCrashServiceUploader::TraceCrashServiceUploader(
net::URLRequestContextGetter* request_context)
- : request_context_(request_context) {
+ : request_context_(request_context), max_upload_bytes_(kMaxUploadBytes) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
@@ -72,6 +72,11 @@ void TraceCrashServiceUploader::SetUploadURL(const std::string& url) {
upload_url_.clear();
}
+void TraceCrashServiceUploader::SetMaxUploadBytes(size_t max_upload_bytes) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ max_upload_bytes_ = max_upload_bytes;
+}
+
void TraceCrashServiceUploader::OnURLFetchComplete(
const net::URLFetcher* source) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -174,9 +179,9 @@ void TraceCrashServiceUploader::DoUploadOnFileThread(
std::string compressed_contents;
if (upload_mode == COMPRESSED_UPLOAD) {
- std::unique_ptr<char[]> compressed_buffer(new char[kMaxUploadBytes]);
+ std::unique_ptr<char[]> compressed_buffer(new char[max_upload_bytes_]);
int compressed_bytes;
- if (!Compress(file_contents, kMaxUploadBytes, compressed_buffer.get(),
+ if (!Compress(file_contents, max_upload_bytes_, compressed_buffer.get(),
&compressed_bytes)) {
OnUploadError("Compressing file failed.");
return;
@@ -184,12 +189,12 @@ void TraceCrashServiceUploader::DoUploadOnFileThread(
compressed_contents =
std::string(compressed_buffer.get(), compressed_bytes);
} else {
- if (file_contents.size() >= kMaxUploadBytes) {
- OnUploadError("File is too large to upload.");
- return;
- }
compressed_contents = file_contents;
}
+ if (compressed_contents.size() > max_upload_bytes_) {
+ OnUploadError("File is too large to upload.");
+ return;
+ }
std::string post_data;
SetupMultipart(product, version, std::move(metadata), "trace.json.gz",
« no previous file with comments | « chrome/browser/tracing/crash_service_uploader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698