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