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 "chrome/browser/tracing/crash_service_uploader.h" | 5 #include "chrome/browser/tracing/crash_service_uploader.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
26 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
27 #include "net/url_request/url_request_context_builder.h" | 27 #include "net/url_request/url_request_context_builder.h" |
28 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
29 #include "third_party/zlib/zlib.h" | 29 #include "third_party/zlib/zlib.h" |
30 #include "url/gurl.h" | 30 #include "url/gurl.h" |
31 | 31 |
32 using std::string; | 32 using std::string; |
33 | 33 |
34 namespace { | 34 namespace { |
| 35 |
35 const char kUploadURL[] = "https://clients2.google.com/cr/staging_report"; | 36 const char kUploadURL[] = "https://clients2.google.com/cr/staging_report"; |
36 const char kUploadContentType[] = "multipart/form-data"; | 37 const char kUploadContentType[] = "multipart/form-data"; |
37 const char kMultipartBoundary[] = | 38 const char kMultipartBoundary[] = |
38 "----**--yradnuoBgoLtrapitluMklaTelgooG--**----"; | 39 "----**--yradnuoBgoLtrapitluMklaTelgooG--**----"; |
39 const int kHttpResponseOk = 200; | 40 const int kHttpResponseOk = 200; |
40 | 41 |
| 42 // Allow up to 10MB for trace upload |
| 43 const int kMaxUploadBytes = 10000000; |
| 44 |
41 } // namespace | 45 } // namespace |
42 | 46 |
43 TraceCrashServiceUploader::TraceCrashServiceUploader( | 47 TraceCrashServiceUploader::TraceCrashServiceUploader( |
44 net::URLRequestContextGetter* request_context) | 48 net::URLRequestContextGetter* request_context) |
45 : request_context_(request_context) { | 49 : request_context_(request_context) { |
46 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
47 const base::CommandLine& command_line = | 51 const base::CommandLine& command_line = |
48 *base::CommandLine::ForCurrentProcess(); | 52 *base::CommandLine::ForCurrentProcess(); |
49 std::string upload_url = kUploadURL; | 53 std::string upload_url = kUploadURL; |
50 if (command_line.HasSwitch(switches::kTraceUploadURL)) { | 54 if (command_line.HasSwitch(switches::kTraceUploadURL)) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 std::string content_type = kUploadContentType; | 298 std::string content_type = kUploadContentType; |
295 content_type.append("; boundary="); | 299 content_type.append("; boundary="); |
296 content_type.append(kMultipartBoundary); | 300 content_type.append(kMultipartBoundary); |
297 | 301 |
298 url_fetcher_ = | 302 url_fetcher_ = |
299 net::URLFetcher::Create(GURL(upload_url), net::URLFetcher::POST, this); | 303 net::URLFetcher::Create(GURL(upload_url), net::URLFetcher::POST, this); |
300 url_fetcher_->SetRequestContext(request_context_); | 304 url_fetcher_->SetRequestContext(request_context_); |
301 url_fetcher_->SetUploadData(content_type, post_data); | 305 url_fetcher_->SetUploadData(content_type, post_data); |
302 url_fetcher_->Start(); | 306 url_fetcher_->Start(); |
303 } | 307 } |
OLD | NEW |