OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tracing/background_tracing_field_trial.h" | 5 #include "chrome/browser/tracing/background_tracing_field_trial.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 void UploadCallback(const std::string& upload_url, | 40 void UploadCallback(const std::string& upload_url, |
41 const scoped_refptr<base::RefCountedString>& file_contents, | 41 const scoped_refptr<base::RefCountedString>& file_contents, |
42 std::unique_ptr<const base::DictionaryValue> metadata, | 42 std::unique_ptr<const base::DictionaryValue> metadata, |
43 base::Closure callback) { | 43 base::Closure callback) { |
44 TraceCrashServiceUploader* uploader = new TraceCrashServiceUploader( | 44 TraceCrashServiceUploader* uploader = new TraceCrashServiceUploader( |
45 g_browser_process->system_request_context()); | 45 g_browser_process->system_request_context()); |
46 | 46 |
47 if (GURL(upload_url).is_valid()) | 47 if (GURL(upload_url).is_valid()) |
48 uploader->SetUploadURL(upload_url); | 48 uploader->SetUploadURL(upload_url); |
49 | 49 |
50 #if defined(OS_ANDROID) || defined(OS_IOS) | 50 #if defined(OS_ANDROID) |
51 auto connection_type = net::NetworkChangeNotifier::GetConnectionType(); | 51 auto connection_type = net::NetworkChangeNotifier::GetConnectionType(); |
52 if (connection_type != net::NetworkChangeNotifier::CONNECTION_WIFI && | 52 if (connection_type != net::NetworkChangeNotifier::CONNECTION_WIFI && |
53 connection_type != net::NetworkChangeNotifier::CONNECTION_ETHERNET && | 53 connection_type != net::NetworkChangeNotifier::CONNECTION_ETHERNET && |
54 connection_type != net::NetworkChangeNotifier::CONNECTION_BLUETOOTH) { | 54 connection_type != net::NetworkChangeNotifier::CONNECTION_BLUETOOTH) { |
55 // Allow only 100KiB for uploads over data. | 55 // Allow only 100KiB for uploads over data. |
56 uploader->SetMaxUploadBytes(100 * 1024); | 56 uploader->SetMaxUploadBytes(100 * 1024); |
57 } | 57 } |
58 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 58 #endif |
59 | 59 |
60 uploader->DoUpload( | 60 uploader->DoUpload( |
61 file_contents->data(), content::TraceUploader::UNCOMPRESSED_UPLOAD, | 61 file_contents->data(), content::TraceUploader::UNCOMPRESSED_UPLOAD, |
62 std::move(metadata), content::TraceUploader::UploadProgressCallback(), | 62 std::move(metadata), content::TraceUploader::UploadProgressCallback(), |
63 base::Bind(&OnUploadComplete, base::Owned(uploader), callback)); | 63 base::Bind(&OnUploadComplete, base::Owned(uploader), callback)); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 void SetConfigTextFilterForTesting(ConfigTextFilterForTesting predicate) { | 68 void SetConfigTextFilterForTesting(ConfigTextFilterForTesting predicate) { |
(...skipping 24 matching lines...) Expand all Loading... |
93 content::BackgroundTracingConfig::FromDict(dict); | 93 content::BackgroundTracingConfig::FromDict(dict); |
94 if (!config) | 94 if (!config) |
95 return; | 95 return; |
96 | 96 |
97 content::BackgroundTracingManager::GetInstance()->SetActiveScenario( | 97 content::BackgroundTracingManager::GetInstance()->SetActiveScenario( |
98 std::move(config), base::Bind(&UploadCallback, upload_url), | 98 std::move(config), base::Bind(&UploadCallback, upload_url), |
99 content::BackgroundTracingManager::ANONYMIZE_DATA); | 99 content::BackgroundTracingManager::ANONYMIZE_DATA); |
100 } | 100 } |
101 | 101 |
102 } // namespace tracing | 102 } // namespace tracing |
OLD | NEW |