1c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org// Copyright 2014 The Chromium Authors. All rights reserved.
2c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org// Use of this source code is governed by a BSD-style license that can be
3c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org// found in the LICENSE file.
4c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org
5c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org#ifndef COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_
6c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org#define COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_
7c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org
818fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org#include <map>
918fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org
10887f3979f0c717e69a8b7d169169bc27eb46d3b5mtklein#include "base/callback_forward.h"
1118fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org#include "base/memory/ref_counted.h"
1218fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org#include "components/domain_reliability/domain_reliability_export.h"
1318fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org#include "url/gurl.h"
149ea53f93e79ba312c4b3943923450a8b4aa57c82tfarina
15732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.orgnamespace net {
1618fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.orgclass URLFetcher;
1718fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.orgclass URLRequest;
18732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.orgclass URLRequestContextGetter;
1918fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org}  // namespace net
20732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org
2118fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.orgnamespace domain_reliability {
2218fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org
2318fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org// Uploads Domain Reliability reports to collectors.
24732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.orgclass DOMAIN_RELIABILITY_EXPORT DomainReliabilityUploader {
25732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org public:
26732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org  typedef base::Callback<void(bool success)> UploadCallback;
27732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org
28732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org  DomainReliabilityUploader();
2918fd2b923a5060175ab4e446e73a73cba581c20dcommit-bot@chromium.org
30  virtual ~DomainReliabilityUploader();
31
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
34  // version.)
35  static scoped_ptr<DomainReliabilityUploader> Create(const scoped_refptr<
36      net::URLRequestContextGetter>& url_request_context_getter);
37
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;
43
44  virtual void set_discard_uploads(bool discard_uploads) = 0;
45
46  static bool URLRequestIsUpload(const net::URLRequest& request);
47};
48
49}  // namespace domain_reliability
50
51#endif  // COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_
52