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_
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"
19 class URLRequestContextGetter
;
22 namespace domain_reliability
{
26 // Uploads Domain Reliability reports to collectors.
27 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityUploader
{
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
; }
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
53 static scoped_ptr
<DomainReliabilityUploader
> Create(
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_