[Eraser strings] Remove unused Supervised User infobar and corresponding strings
[chromium-blink-merge.git] / components / domain_reliability / uploader.h
blob18f6bff3b7f5fda31ca0b42373c62678b1547651
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_
8 #include <map>
10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "components/domain_reliability/domain_reliability_export.h"
14 #include "url/gurl.h"
16 namespace net {
17 class URLFetcher;
18 class URLRequest;
19 class URLRequestContextGetter;
20 } // namespace net
22 namespace domain_reliability {
24 class MockableTime;
26 // Uploads Domain Reliability reports to collectors.
27 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityUploader {
28 public:
29 struct UploadResult {
30 enum UploadStatus {
31 FAILURE,
32 SUCCESS,
33 RETRY_AFTER,
36 bool is_success() const { return status == SUCCESS; }
37 bool is_failure() const { return status == FAILURE; }
38 bool is_retry_after() const { return status == RETRY_AFTER; }
40 UploadStatus status;
41 base::TimeDelta retry_after;
44 typedef base::Callback<void(const UploadResult& result)> UploadCallback;
46 DomainReliabilityUploader();
48 virtual ~DomainReliabilityUploader();
50 // Creates an uploader that uses the given |url_request_context_getter| to
51 // get a URLRequestContext to use for uploads. (See test_util.h for a mock
52 // version.)
53 static scoped_ptr<DomainReliabilityUploader> Create(
54 MockableTime* time,
55 const scoped_refptr<
56 net::URLRequestContextGetter>& url_request_context_getter);
58 // Uploads |report_json| to |upload_url| and calls |callback| when the upload
59 // has either completed or failed.
60 virtual void UploadReport(const std::string& report_json,
61 const GURL& upload_url,
62 const UploadCallback& callback) = 0;
64 virtual void set_discard_uploads(bool discard_uploads) = 0;
66 static bool URLRequestIsUpload(const net::URLRequest& request);
69 } // namespace domain_reliability
71 #endif // COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_