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> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 | 10 |
12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
18 #include "content/public/browser/trace_uploader.h" | 17 #include "content/public/browser/trace_uploader.h" |
(...skipping 22 matching lines...) Expand all Loading... |
41 void SetUploadURL(const std::string& url); | 40 void SetUploadURL(const std::string& url); |
42 | 41 |
43 // net::URLFetcherDelegate implementation. | 42 // net::URLFetcherDelegate implementation. |
44 void OnURLFetchComplete(const net::URLFetcher* source) override; | 43 void OnURLFetchComplete(const net::URLFetcher* source) override; |
45 void OnURLFetchUploadProgress(const net::URLFetcher* source, | 44 void OnURLFetchUploadProgress(const net::URLFetcher* source, |
46 int64 current, | 45 int64 current, |
47 int64 total) override; | 46 int64 total) override; |
48 | 47 |
49 // content::TraceUploader | 48 // content::TraceUploader |
50 void DoUpload(const std::string& file_contents, | 49 void DoUpload(const std::string& file_contents, |
| 50 scoped_ptr<base::DictionaryValue> metadata, |
51 const UploadProgressCallback& progress_callback, | 51 const UploadProgressCallback& progress_callback, |
52 const UploadDoneCallback& done_callback) override; | 52 const UploadDoneCallback& done_callback) override; |
53 | 53 |
54 private: | 54 private: |
55 void DoUploadOnFileThread(const std::string& file_contents, | 55 void DoUploadOnFileThread(const std::string& file_contents, |
56 const std::string& upload_url, | 56 const std::string& upload_url, |
| 57 scoped_ptr<base::DictionaryValue> metadata, |
57 const UploadProgressCallback& progress_callback, | 58 const UploadProgressCallback& progress_callback, |
58 const UploadDoneCallback& done_callback); | 59 const UploadDoneCallback& done_callback); |
59 // Sets up a multipart body to be uploaded. The body is produced according | 60 // Sets up a multipart body to be uploaded. The body is produced according |
60 // to RFC 2046. | 61 // to RFC 2046. |
61 void SetupMultipart(const std::string& product, | 62 void SetupMultipart(const std::string& product, |
62 const std::string& version, | 63 const std::string& version, |
| 64 scoped_ptr<base::DictionaryValue> metadata, |
63 const std::string& trace_filename, | 65 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 void AddTraceFile(const std::string& trace_filename, | 68 void AddTraceFile(const std::string& trace_filename, |
67 const std::string& trace_contents, | 69 const std::string& trace_contents, |
68 std::string* post_data); | 70 std::string* post_data); |
69 // Compresses the input and returns whether compression was successful. | 71 // Compresses the input and returns whether compression was successful. |
70 bool Compress(std::string input, | 72 bool Compress(std::string input, |
71 int max_compressed_bytes, | 73 int max_compressed_bytes, |
72 char* compressed_contents, | 74 char* compressed_contents, |
73 int* compressed_bytes); | 75 int* compressed_bytes); |
74 void CreateAndStartURLFetcher(const std::string& upload_url, | 76 void CreateAndStartURLFetcher(const std::string& upload_url, |
75 const std::string& post_data); | 77 const std::string& post_data); |
76 void OnUploadError(std::string error_message); | 78 void OnUploadError(std::string error_message); |
77 | 79 |
78 scoped_ptr<net::URLFetcher> url_fetcher_; | 80 scoped_ptr<net::URLFetcher> url_fetcher_; |
79 UploadProgressCallback progress_callback_; | 81 UploadProgressCallback progress_callback_; |
80 UploadDoneCallback done_callback_; | 82 UploadDoneCallback done_callback_; |
81 | 83 |
82 net::URLRequestContextGetter* request_context_; | 84 net::URLRequestContextGetter* request_context_; |
83 | 85 |
84 std::string upload_url_; | 86 std::string upload_url_; |
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 |