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

Side by Side Diff: chrome/browser/supervised_user/experimental/safe_search_url_reporter.h

Issue 1878143002: Convert //chrome/browser/supervised_user from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_ 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_ 6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include <memory>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
9 #include "google_apis/gaia/oauth2_token_service.h" 12 #include "google_apis/gaia/oauth2_token_service.h"
10 #include "net/url_request/url_fetcher_delegate.h" 13 #include "net/url_request/url_fetcher_delegate.h"
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 class GURL; 16 class GURL;
16 class Profile; 17 class Profile;
17 18
18 namespace net { 19 namespace net {
19 class URLFetcher; 20 class URLFetcher;
20 class URLReportContextGetter; 21 class URLReportContextGetter;
21 } 22 }
22 23
23 class SafeSearchURLReporter : public OAuth2TokenService::Consumer, 24 class SafeSearchURLReporter : public OAuth2TokenService::Consumer,
24 public net::URLFetcherDelegate { 25 public net::URLFetcherDelegate {
25 public: 26 public:
26 using SuccessCallback = base::Callback<void(bool)>; 27 using SuccessCallback = base::Callback<void(bool)>;
27 28
28 SafeSearchURLReporter(OAuth2TokenService* oauth2_token_service, 29 SafeSearchURLReporter(OAuth2TokenService* oauth2_token_service,
29 const std::string& account_id, 30 const std::string& account_id,
30 net::URLRequestContextGetter* context); 31 net::URLRequestContextGetter* context);
31 ~SafeSearchURLReporter() override; 32 ~SafeSearchURLReporter() override;
32 33
33 static scoped_ptr<SafeSearchURLReporter> CreateWithProfile(Profile* profile); 34 static std::unique_ptr<SafeSearchURLReporter> CreateWithProfile(
35 Profile* profile);
34 36
35 void ReportUrl(const GURL& url, const SuccessCallback& callback); 37 void ReportUrl(const GURL& url, const SuccessCallback& callback);
36 38
37 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; } 39 void set_url_fetcher_id_for_testing(int id) { url_fetcher_id_ = id; }
38 40
39 private: 41 private:
40 struct Report; 42 struct Report;
41 using ReportIterator = std::vector<scoped_ptr<Report>>::iterator; 43 using ReportIterator = std::vector<std::unique_ptr<Report>>::iterator;
42 44
43 // OAuth2TokenService::Consumer implementation: 45 // OAuth2TokenService::Consumer implementation:
44 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 46 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
45 const std::string& access_token, 47 const std::string& access_token,
46 const base::Time& expiration_time) override; 48 const base::Time& expiration_time) override;
47 void OnGetTokenFailure(const OAuth2TokenService::Request* request, 49 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
48 const GoogleServiceAuthError& error) override; 50 const GoogleServiceAuthError& error) override;
49 51
50 // net::URLFetcherDelegate implementation. 52 // net::URLFetcherDelegate implementation.
51 void OnURLFetchComplete(const net::URLFetcher* source) override; 53 void OnURLFetchComplete(const net::URLFetcher* source) override;
52 54
53 // Requests an access token, which is the first thing we need. This is where 55 // Requests an access token, which is the first thing we need. This is where
54 // we restart when the returned access token has expired. 56 // we restart when the returned access token has expired.
55 void StartFetching(Report* Report); 57 void StartFetching(Report* Report);
56 58
57 void DispatchResult(ReportIterator it, bool success); 59 void DispatchResult(ReportIterator it, bool success);
58 60
59 OAuth2TokenService* oauth2_token_service_; 61 OAuth2TokenService* oauth2_token_service_;
60 std::string account_id_; 62 std::string account_id_;
61 net::URLRequestContextGetter* context_; 63 net::URLRequestContextGetter* context_;
62 int url_fetcher_id_; 64 int url_fetcher_id_;
63 65
64 std::vector<scoped_ptr<Report>> reports_; 66 std::vector<std::unique_ptr<Report>> reports_;
65 67
66 DISALLOW_COPY_AND_ASSIGN(SafeSearchURLReporter); 68 DISALLOW_COPY_AND_ASSIGN(SafeSearchURLReporter);
67 }; 69 };
68 70
69 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_ H_ 71 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SAFE_SEARCH_URL_REPORTER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698