| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_PUBLIC_BROWSER_TRACE_UPLOADER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_TRACE_UPLOADER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_TRACE_UPLOADER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_TRACE_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // Used to implement a trace upload service for use in about://tracing, | 17 // Used to implement a trace upload service for use in about://tracing, |
| 17 // which gets requested through the TracingDelegate. | 18 // which gets requested through the TracingDelegate. |
| 18 class TraceUploader { | 19 class TraceUploader { |
| 19 public: | 20 public: |
| 20 // This should be called when the tracing is complete. | 21 // This should be called when the tracing is complete. |
| 21 // The bool denotes success or failure, the string is feedback | 22 // The bool denotes success or failure, the string is feedback |
| 22 // to show in the Tracing UI. | 23 // to show in the Tracing UI. |
| 23 typedef base::Callback<void(bool, const std::string&)> UploadDoneCallback; | 24 typedef base::Callback<void(bool, const std::string&)> UploadDoneCallback; |
| 24 // Call this to update the progress UI with the current bytes uploaded, | 25 // Call this to update the progress UI with the current bytes uploaded, |
| 25 // as well as the total. | 26 // as well as the total. |
| 26 typedef base::Callback<void(int64_t, int64_t)> UploadProgressCallback; | 27 typedef base::Callback<void(int64_t, int64_t)> UploadProgressCallback; |
| 27 | 28 |
| 28 virtual ~TraceUploader() {} | 29 virtual ~TraceUploader() {} |
| 29 | 30 |
| 30 enum UploadMode { COMPRESSED_UPLOAD, UNCOMPRESSED_UPLOAD }; | 31 enum UploadMode { COMPRESSED_UPLOAD, UNCOMPRESSED_UPLOAD }; |
| 31 | 32 |
| 32 // Compresses and uploads the given file contents. | 33 // Compresses and uploads the given file contents. |
| 33 virtual void DoUpload(const std::string& file_contents, | 34 virtual void DoUpload(const std::string& file_contents, |
| 34 UploadMode upload_mode, | 35 UploadMode upload_mode, |
| 35 scoped_ptr<const base::DictionaryValue> metadata, | 36 std::unique_ptr<const base::DictionaryValue> metadata, |
| 36 const UploadProgressCallback& progress_callback, | 37 const UploadProgressCallback& progress_callback, |
| 37 const UploadDoneCallback& done_callback) = 0; | 38 const UploadDoneCallback& done_callback) = 0; |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 } // namespace content | 41 } // namespace content |
| 41 | 42 |
| 42 #endif // CONTENT_PUBLIC_BROWSER_TRACE_UPLOADER_H_ | 43 #endif // CONTENT_PUBLIC_BROWSER_TRACE_UPLOADER_H_ |
| OLD | NEW |