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

Side by Side Diff: chrome/browser/safe_browsing/client_side_model_loader.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Helper class loads models for client-side phishing detection 5 // Helper class loads models for client-side phishing detection
6 // from the the SafeBrowsing backends. 6 // from the the SafeBrowsing backends.
7 // 7 //
8 // This class is not thread-safe and expects all calls to be made on the UI 8 // This class is not thread-safe and expects all calls to be made on the UI
9 // thread. 9 // thread.
10 10
11 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_MODEL_LOADER_H_ 11 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_MODEL_LOADER_H_
12 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_MODEL_LOADER_H_ 12 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_MODEL_LOADER_H_
13 13
14 #include <stddef.h> 14 #include <stddef.h>
15 #include <stdint.h> 15 #include <stdint.h>
16 16
17 #include <memory>
17 #include <string> 18 #include <string>
18 19
19 #include "base/callback.h" 20 #include "base/callback.h"
20 #include "base/gtest_prod_util.h" 21 #include "base/gtest_prod_util.h"
21 #include "base/macros.h" 22 #include "base/macros.h"
22 #include "base/memory/linked_ptr.h" 23 #include "base/memory/linked_ptr.h"
23 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
24 #include "base/memory/scoped_ptr.h"
25 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "net/url_request/url_fetcher_delegate.h" 27 #include "net/url_request/url_fetcher_delegate.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 namespace base { 30 namespace base {
31 class TimeDelta; 31 class TimeDelta;
32 } 32 }
33 33
34 namespace net { 34 namespace net {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // valid hashes in the model. 107 // valid hashes in the model.
108 static bool ModelHasValidHashIds(const ClientSideModel& model); 108 static bool ModelHasValidHashIds(const ClientSideModel& model);
109 109
110 // The name of the model is the last component of the URL path. 110 // The name of the model is the last component of the URL path.
111 const std::string name_; 111 const std::string name_;
112 // Full URL of the model. 112 // Full URL of the model.
113 const GURL url_; 113 const GURL url_;
114 114
115 // If the model isn't yet loaded, model_str_ will be empty. 115 // If the model isn't yet loaded, model_str_ will be empty.
116 std::string model_str_; 116 std::string model_str_;
117 scoped_ptr<ClientSideModel> model_; 117 std::unique_ptr<ClientSideModel> model_;
118 scoped_ptr<net::URLFetcher> fetcher_; 118 std::unique_ptr<net::URLFetcher> fetcher_;
119 119
120 // Callback to invoke when we've got a new model. CSD will send it around. 120 // Callback to invoke when we've got a new model. CSD will send it around.
121 base::Closure update_renderers_callback_; 121 base::Closure update_renderers_callback_;
122 122
123 // Not owned, must outlive this obj or be NULL. 123 // Not owned, must outlive this obj or be NULL.
124 net::URLRequestContextGetter* request_context_getter_; 124 net::URLRequestContextGetter* request_context_getter_;
125 125
126 // Used to protect the delayed callback to StartFetchModel() 126 // Used to protect the delayed callback to StartFetchModel()
127 base::WeakPtrFactory<ModelLoader> weak_factory_; 127 base::WeakPtrFactory<ModelLoader> weak_factory_;
128 128
129 friend class ClientSideDetectionServiceTest; 129 friend class ClientSideDetectionServiceTest;
130 friend class ModelLoaderTest; 130 friend class ModelLoaderTest;
131 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, FetchModelTest); 131 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, FetchModelTest);
132 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, ModelHasValidHashIds); 132 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, ModelHasValidHashIds);
133 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, ModelNamesTest); 133 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, ModelNamesTest);
134 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, RescheduleFetchTest); 134 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, RescheduleFetchTest);
135 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, UpdateRenderersTest); 135 FRIEND_TEST_ALL_PREFIXES(ModelLoaderTest, UpdateRenderersTest);
136 FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest, 136 FRIEND_TEST_ALL_PREFIXES(ClientSideDetectionServiceTest,
137 SetEnabledAndRefreshState); 137 SetEnabledAndRefreshState);
138 DISALLOW_COPY_AND_ASSIGN(ModelLoader); 138 DISALLOW_COPY_AND_ASSIGN(ModelLoader);
139 }; 139 };
140 140
141 } // namespace safe_browsing 141 } // namespace safe_browsing
142 142
143 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_MODEL_LOADER_H_ 143 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_MODEL_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698