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 "base/callback.h" | |
9 #include "net/base/net_export.h" | |
10 #include "net/url_request/url_fetcher.h" | |
11 #include "net/url_request/url_fetcher_delegate.h" | |
12 #include "net/url_request/url_request_context_getter.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace net { | |
16 | |
17 // Uploads already-serialized reports and converts responses to one of the | |
18 // specified outcomes. | |
19 class NET_EXPORT ReportingUploader { | |
20 public: | |
21 enum Outcome { SUCCESS, REMOVE_ENDPOINT, FAILURE }; | |
shivanisha
2017/03/28 19:57:14
prefer enum class over enum for type safety.
Julia Tuttle
2017/03/28 20:36:34
Done.
| |
22 | |
23 using Callback = base::Callback<void(Outcome outcome)>; | |
24 | |
25 static const char kUploadContentType[]; | |
26 | |
27 virtual ~ReportingUploader(); | |
28 | |
29 // Starts to upload the reports in |json| (properly tagged as JSON data) to | |
30 // |url|, and calls |callback| when complete (whether successful or not). | |
31 virtual void StartUpload(const GURL& url, | |
32 const std::string& json, | |
33 const Callback& callback) = 0; | |
34 | |
35 // Creates a real implementation of |ReportingUploader| that uploads reports | |
36 // using |context|. | |
37 static std::unique_ptr<ReportingUploader> Create( | |
38 const URLRequestContext* context); | |
39 }; | |
40 | |
41 } // namespace net | |
42 | |
43 #endif // NET_REPORTING_REPORTING_UPLOADER_H_ | |
OLD | NEW |