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 #ifndef CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ |
6 #define CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ | 6 #define CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 20 matching lines...) Expand all Loading... |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 // TraceCrashServiceUploader uploads traces to the Chrome crash service. | 33 // TraceCrashServiceUploader uploads traces to the Chrome crash service. |
34 class TraceCrashServiceUploader : public content::TraceUploader, | 34 class TraceCrashServiceUploader : public content::TraceUploader, |
35 public net::URLFetcherDelegate { | 35 public net::URLFetcherDelegate { |
36 public: | 36 public: |
37 explicit TraceCrashServiceUploader( | 37 explicit TraceCrashServiceUploader( |
38 net::URLRequestContextGetter* request_context); | 38 net::URLRequestContextGetter* request_context); |
39 ~TraceCrashServiceUploader() override; | 39 ~TraceCrashServiceUploader() override; |
40 | 40 |
| 41 void SetUploadURL(const std::string& url); |
| 42 |
41 // net::URLFetcherDelegate implementation. | 43 // net::URLFetcherDelegate implementation. |
42 void OnURLFetchComplete(const net::URLFetcher* source) override; | 44 void OnURLFetchComplete(const net::URLFetcher* source) override; |
43 void OnURLFetchUploadProgress(const net::URLFetcher* source, | 45 void OnURLFetchUploadProgress(const net::URLFetcher* source, |
44 int64 current, | 46 int64 current, |
45 int64 total) override; | 47 int64 total) override; |
46 | 48 |
47 // content::TraceUploader | 49 // content::TraceUploader |
48 void DoUpload(const std::string& file_contents, | 50 void DoUpload(const std::string& file_contents, |
49 const UploadProgressCallback& progress_callback, | 51 const UploadProgressCallback& progress_callback, |
50 const UploadDoneCallback& done_callback) override; | 52 const UploadDoneCallback& done_callback) override; |
51 | 53 |
52 private: | 54 private: |
53 void DoUploadOnFileThread(const std::string& file_contents, | 55 void DoUploadOnFileThread(const std::string& file_contents, |
| 56 const std::string& upload_url, |
54 const UploadProgressCallback& progress_callback, | 57 const UploadProgressCallback& progress_callback, |
55 const UploadDoneCallback& done_callback); | 58 const UploadDoneCallback& done_callback); |
56 // Sets up a multipart body to be uploaded. The body is produced according | 59 // Sets up a multipart body to be uploaded. The body is produced according |
57 // to RFC 2046. | 60 // to RFC 2046. |
58 void SetupMultipart(const std::string& product, | 61 void SetupMultipart(const std::string& product, |
59 const std::string& version, | 62 const std::string& version, |
60 const std::string& trace_filename, | 63 const std::string& trace_filename, |
61 const std::string& trace_contents, | 64 const std::string& trace_contents, |
62 std::string* post_data); | 65 std::string* post_data); |
63 void AddTraceFile(const std::string& trace_filename, | 66 void AddTraceFile(const std::string& trace_filename, |
64 const std::string& trace_contents, | 67 const std::string& trace_contents, |
65 std::string* post_data); | 68 std::string* post_data); |
66 // Compresses the input and returns whether compression was successful. | 69 // Compresses the input and returns whether compression was successful. |
67 bool Compress(std::string input, | 70 bool Compress(std::string input, |
68 int max_compressed_bytes, | 71 int max_compressed_bytes, |
69 char* compressed_contents, | 72 char* compressed_contents, |
70 int* compressed_bytes); | 73 int* compressed_bytes); |
71 void CreateAndStartURLFetcher(const std::string& upload_url, | 74 void CreateAndStartURLFetcher(const std::string& upload_url, |
72 const std::string& post_data); | 75 const std::string& post_data); |
73 void OnUploadError(std::string error_message); | 76 void OnUploadError(std::string error_message); |
74 | 77 |
75 scoped_ptr<net::URLFetcher> url_fetcher_; | 78 scoped_ptr<net::URLFetcher> url_fetcher_; |
76 UploadProgressCallback progress_callback_; | 79 UploadProgressCallback progress_callback_; |
77 UploadDoneCallback done_callback_; | 80 UploadDoneCallback done_callback_; |
78 | 81 |
79 net::URLRequestContextGetter* request_context_; | 82 net::URLRequestContextGetter* request_context_; |
80 | 83 |
| 84 std::string upload_url_; |
| 85 |
81 DISALLOW_COPY_AND_ASSIGN(TraceCrashServiceUploader); | 86 DISALLOW_COPY_AND_ASSIGN(TraceCrashServiceUploader); |
82 }; | 87 }; |
83 | 88 |
84 #endif // CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ | 89 #endif // CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ |
OLD | NEW |