OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_REPORTING_REPORTING_UPLOADER_H_ |
| 6 #define NET_REPORTING_REPORTING_UPLOADER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "net/base/net_export.h" |
| 13 |
| 14 class GURL; |
| 15 |
| 16 namespace net { |
| 17 |
| 18 class URLRequestContext; |
| 19 |
| 20 // Uploads already-serialized reports and converts responses to one of the |
| 21 // specified outcomes. |
| 22 class NET_EXPORT ReportingUploader { |
| 23 public: |
| 24 enum class Outcome { SUCCESS, REMOVE_ENDPOINT, FAILURE }; |
| 25 |
| 26 using Callback = base::Callback<void(Outcome outcome)>; |
| 27 |
| 28 static const char kUploadContentType[]; |
| 29 |
| 30 virtual ~ReportingUploader(); |
| 31 |
| 32 // Starts to upload the reports in |json| (properly tagged as JSON data) to |
| 33 // |url|, and calls |callback| when complete (whether successful or not). |
| 34 virtual void StartUpload(const GURL& url, |
| 35 const std::string& json, |
| 36 const Callback& callback) = 0; |
| 37 |
| 38 // Creates a real implementation of |ReportingUploader| that uploads reports |
| 39 // using |context|. |
| 40 static std::unique_ptr<ReportingUploader> Create( |
| 41 const URLRequestContext* context); |
| 42 }; |
| 43 |
| 44 } // namespace net |
| 45 |
| 46 #endif // NET_REPORTING_REPORTING_UPLOADER_H_ |
OLD | NEW |