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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 void OnURLFetchComplete(const net::URLFetcher* source) override; | 42 void OnURLFetchComplete(const net::URLFetcher* source) override; |
43 void OnURLFetchUploadProgress(const net::URLFetcher* source, | 43 void OnURLFetchUploadProgress(const net::URLFetcher* source, |
44 int64 current, | 44 int64 current, |
45 int64 total) override; | 45 int64 total) override; |
46 | 46 |
47 // content::TraceUploader | 47 // content::TraceUploader |
48 void DoUpload(const std::string& file_contents, | 48 void DoUpload(const std::string& file_contents, |
49 const UploadProgressCallback& progress_callback, | 49 const UploadProgressCallback& progress_callback, |
50 const UploadDoneCallback& done_callback) override; | 50 const UploadDoneCallback& done_callback) override; |
51 | 51 |
| 52 void SetUploadURL(const std::string&); |
| 53 |
52 private: | 54 private: |
53 void DoUploadOnFileThread(const std::string& file_contents, | 55 void DoUploadOnFileThread(const std::string& file_contents, |
54 const UploadProgressCallback& progress_callback, | 56 const UploadProgressCallback& progress_callback, |
55 const UploadDoneCallback& done_callback); | 57 const UploadDoneCallback& done_callback); |
56 // Sets up a multipart body to be uploaded. The body is produced according | 58 // Sets up a multipart body to be uploaded. The body is produced according |
57 // to RFC 2046. | 59 // to RFC 2046. |
58 void SetupMultipart(const std::string& product, | 60 void SetupMultipart(const std::string& product, |
59 const std::string& version, | 61 const std::string& version, |
60 const std::string& trace_filename, | 62 const std::string& trace_filename, |
61 const std::string& trace_contents, | 63 const std::string& trace_contents, |
62 std::string* post_data); | 64 std::string* post_data); |
63 void AddTraceFile(const std::string& trace_filename, | 65 void AddTraceFile(const std::string& trace_filename, |
64 const std::string& trace_contents, | 66 const std::string& trace_contents, |
65 std::string* post_data); | 67 std::string* post_data); |
66 // Compresses the input and returns whether compression was successful. | 68 // Compresses the input and returns whether compression was successful. |
67 bool Compress(std::string input, | 69 bool Compress(std::string input, |
68 int max_compressed_bytes, | 70 int max_compressed_bytes, |
69 char* compressed_contents, | 71 char* compressed_contents, |
70 int* compressed_bytes); | 72 int* compressed_bytes); |
71 void CreateAndStartURLFetcher(const std::string& upload_url, | 73 void CreateAndStartURLFetcher(const std::string& upload_url, |
72 const std::string& post_data); | 74 const std::string& post_data); |
73 void OnUploadError(std::string error_message); | 75 void OnUploadError(std::string error_message); |
74 | 76 |
75 scoped_ptr<net::URLFetcher> url_fetcher_; | 77 scoped_ptr<net::URLFetcher> url_fetcher_; |
76 UploadProgressCallback progress_callback_; | 78 UploadProgressCallback progress_callback_; |
77 UploadDoneCallback done_callback_; | 79 UploadDoneCallback done_callback_; |
| 80 std::string upload_url_; |
78 | 81 |
79 net::URLRequestContextGetter* request_context_; | 82 net::URLRequestContextGetter* request_context_; |
80 | 83 |
81 DISALLOW_COPY_AND_ASSIGN(TraceCrashServiceUploader); | 84 DISALLOW_COPY_AND_ASSIGN(TraceCrashServiceUploader); |
82 }; | 85 }; |
83 | 86 |
84 #endif // CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ | 87 #endif // CHROME_BROWSER_TRACING_CRASH_SERVICE_UPLOADER_H_ |
OLD | NEW |