Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/incident_report_uploader_impl.h

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_REPORT_UPLOADER _IMPL_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_REPORT_UPLOADER _IMPL_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_REPORT_UPLOADER _IMPL_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_REPORT_UPLOADER _IMPL_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/safe_browsing/incident_reporting/incident_report_upload er.h" 14 #include "chrome/browser/safe_browsing/incident_reporting/incident_report_upload er.h"
15 #include "net/url_request/url_fetcher_delegate.h" 15 #include "net/url_request/url_fetcher_delegate.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace net { 18 namespace net {
19 class URLFetcher; 19 class URLFetcher;
20 class URLRequestContextGetter; 20 class URLRequestContextGetter;
21 } // namespace net 21 } // namespace net
22 22
23 namespace safe_browsing { 23 namespace safe_browsing {
24 24
25 class ClientIncidentReport; 25 class ClientIncidentReport;
26 26
27 // An uploader of incident reports. A report is issued via the UploadReport 27 // An uploader of incident reports. A report is issued via the UploadReport
28 // method. The upload can be cancelled by deleting the returned instance. The 28 // method. The upload can be cancelled by deleting the returned instance. The
29 // instance is no longer usable after the delegate is notified, and may safely 29 // instance is no longer usable after the delegate is notified, and may safely
30 // be destroyed by the delegate. 30 // be destroyed by the delegate.
31 class IncidentReportUploaderImpl : public IncidentReportUploader, 31 class IncidentReportUploaderImpl : public IncidentReportUploader,
32 public net::URLFetcherDelegate { 32 public net::URLFetcherDelegate {
33 public: 33 public:
34 // The id associated with the URLFetcher, for use by tests. 34 // The id associated with the URLFetcher, for use by tests.
35 static const int kTestUrlFetcherId; 35 static const int kTestUrlFetcherId;
36 36
37 ~IncidentReportUploaderImpl() override; 37 ~IncidentReportUploaderImpl() override;
38 38
39 // Uploads a report with a caller-provided URL context. |callback| will be run 39 // Uploads a report with a caller-provided URL context. |callback| will be run
40 // when the upload is complete. Returns NULL if |report| cannot be serialized 40 // when the upload is complete. Returns NULL if |report| cannot be serialized
41 // for transmission, in which case the delegate is not notified. 41 // for transmission, in which case the delegate is not notified.
42 static scoped_ptr<IncidentReportUploader> UploadReport( 42 static std::unique_ptr<IncidentReportUploader> UploadReport(
43 const OnResultCallback& callback, 43 const OnResultCallback& callback,
44 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 44 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
45 const ClientIncidentReport& report); 45 const ClientIncidentReport& report);
46 46
47 private: 47 private:
48 IncidentReportUploaderImpl( 48 IncidentReportUploaderImpl(
49 const OnResultCallback& callback, 49 const OnResultCallback& callback,
50 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 50 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
51 const std::string& post_data); 51 const std::string& post_data);
52 52
53 // Returns the URL to which incident reports are to be sent. 53 // Returns the URL to which incident reports are to be sent.
54 static GURL GetIncidentReportUrl(); 54 static GURL GetIncidentReportUrl();
55 55
56 // net::URLFetcherDelegate methods. 56 // net::URLFetcherDelegate methods.
57 void OnURLFetchComplete(const net::URLFetcher* source) override; 57 void OnURLFetchComplete(const net::URLFetcher* source) override;
58 58
59 // The underlying URL fetcher. The instance is alive from construction through 59 // The underlying URL fetcher. The instance is alive from construction through
60 // OnURLFetchComplete. 60 // OnURLFetchComplete.
61 scoped_ptr<net::URLFetcher> url_fetcher_; 61 std::unique_ptr<net::URLFetcher> url_fetcher_;
62 62
63 // The time at which the upload was initiated. 63 // The time at which the upload was initiated.
64 base::TimeTicks time_begin_; 64 base::TimeTicks time_begin_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(IncidentReportUploaderImpl); 66 DISALLOW_COPY_AND_ASSIGN(IncidentReportUploaderImpl);
67 }; 67 };
68 68
69 } // namespace safe_browsing 69 } // namespace safe_browsing
70 70
71 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_REPORT_UPLOA DER_IMPL_H_ 71 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_REPORT_UPLOA DER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698