| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_ | 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_ |
| 6 #define COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_ | 6 #define COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "components/domain_reliability/domain_reliability_export.h" | 12 #include "components/domain_reliability/domain_reliability_export.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 class URLFetcher; | 16 class URLFetcher; |
| 17 class URLRequest; | 17 class URLRequest; |
| 18 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
| 19 } // namespace net | 19 } // namespace net |
| 20 | 20 |
| 21 namespace domain_reliability { | 21 namespace domain_reliability { |
| 22 | 22 |
| 23 // Uploads Domain Reliability reports to collectors. |
| 23 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityUploader { | 24 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityUploader { |
| 24 public: | 25 public: |
| 25 typedef base::Callback<void(bool success)> UploadCallback; | 26 typedef base::Callback<void(bool success)> UploadCallback; |
| 26 | 27 |
| 27 DomainReliabilityUploader(); | 28 DomainReliabilityUploader(); |
| 29 |
| 28 virtual ~DomainReliabilityUploader(); | 30 virtual ~DomainReliabilityUploader(); |
| 29 | 31 |
| 30 static scoped_ptr<DomainReliabilityUploader> Create( | 32 // Creates an uploader that uses the given |url_request_context_getter| to |
| 31 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | 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); |
| 32 | 37 |
| 38 // Uploads |report_json| to |upload_url| and calls |callback| when the upload |
| 39 // has either completed or failed. |
| 33 virtual void UploadReport(const std::string& report_json, | 40 virtual void UploadReport(const std::string& report_json, |
| 34 const GURL& upload_url, | 41 const GURL& upload_url, |
| 35 const UploadCallback& callback) = 0; | 42 const UploadCallback& callback) = 0; |
| 36 | 43 |
| 37 static bool URLRequestIsUpload(const net::URLRequest& request); | 44 static bool URLRequestIsUpload(const net::URLRequest& request); |
| 38 }; | 45 }; |
| 39 | 46 |
| 40 } // namespace domain_reliability | 47 } // namespace domain_reliability |
| 41 | 48 |
| 42 #endif // COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_ | 49 #endif // COMPONENTS_DOMAIN_RELIABILITY_UPLOADER_H_ |
| OLD | NEW |