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 "components/domain_reliability/domain_reliability_export.h"
18 class URLRequestContextGetter
;
21 namespace domain_reliability
{
23 // Uploads Domain Reliability reports to collectors.
24 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityUploader
{
26 typedef base::Callback
<void(bool success
)> UploadCallback
;
28 DomainReliabilityUploader();
30 virtual ~DomainReliabilityUploader();
32 // Creates an uploader that uses the given |url_request_context_getter| to
33 // get a URLRequestContext to use for uploads. (See test_util.h for a mock
35 static scoped_ptr
<DomainReliabilityUploader
> Create(const scoped_refptr
<
36 net::URLRequestContextGetter
>& url_request_context_getter
);
38 // Uploads |report_json| to |upload_url| and calls |callback| when the upload
39 // has either completed or failed.
40 virtual void UploadReport(const std::string
& report_json
,
41 const GURL
& upload_url
,
42 const UploadCallback
& callback
) = 0;
44 virtual void set_discard_uploads(bool discard_uploads
) = 0;
46 static bool URLRequestIsUpload(const net::URLRequest
& request
);
49 } // namespace domain_reliability
51 #endif // COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_