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

Side by Side Diff: extensions/browser/api/storage/storage_frontend_unittest.cc

Issue 1902873002: Convert //extensions/browser/api 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 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 #include "extensions/browser/api/storage/storage_frontend.h"
6
7 #include <memory>
8
5 #include "base/bind.h" 9 #include "base/bind.h"
6 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
11 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
12 #include "content/public/test/test_browser_context.h" 15 #include "content/public/test/test_browser_context.h"
13 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
14 #include "extensions/browser/api/extensions_api_client.h" 17 #include "extensions/browser/api/extensions_api_client.h"
15 #include "extensions/browser/api/storage/settings_namespace.h" 18 #include "extensions/browser/api/storage/settings_namespace.h"
16 #include "extensions/browser/api/storage/settings_test_util.h" 19 #include "extensions/browser/api/storage/settings_test_util.h"
17 #include "extensions/browser/api/storage/storage_frontend.h"
18 #include "extensions/browser/extensions_test.h" 20 #include "extensions/browser/extensions_test.h"
19 #include "extensions/browser/value_store/value_store.h" 21 #include "extensions/browser/value_store/value_store.h"
20 #include "extensions/browser/value_store/value_store_factory_impl.h" 22 #include "extensions/browser/value_store/value_store_factory_impl.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 24
23 using content::BrowserThread; 25 using content::BrowserThread;
24 26
25 namespace extensions { 27 namespace extensions {
26 28
27 namespace settings = settings_namespace; 29 namespace settings = settings_namespace;
(...skipping 29 matching lines...) Expand all
57 ExtensionsTest::TearDown(); 59 ExtensionsTest::TearDown();
58 } 60 }
59 61
60 protected: 62 protected:
61 void ResetFrontend() { 63 void ResetFrontend() {
62 frontend_ = 64 frontend_ =
63 StorageFrontend::CreateForTesting(storage_factory_, browser_context()); 65 StorageFrontend::CreateForTesting(storage_factory_, browser_context());
64 } 66 }
65 67
66 base::ScopedTempDir temp_dir_; 68 base::ScopedTempDir temp_dir_;
67 scoped_ptr<StorageFrontend> frontend_; 69 std::unique_ptr<StorageFrontend> frontend_;
68 scoped_refptr<ValueStoreFactoryImpl> storage_factory_; 70 scoped_refptr<ValueStoreFactoryImpl> storage_factory_;
69 71
70 private: 72 private:
71 base::MessageLoop message_loop_; 73 base::MessageLoop message_loop_;
72 content::TestBrowserThread ui_thread_; 74 content::TestBrowserThread ui_thread_;
73 content::TestBrowserThread file_thread_; 75 content::TestBrowserThread file_thread_;
74 ExtensionsAPIClient extensions_api_client_; 76 ExtensionsAPIClient extensions_api_client_;
75 }; 77 };
76 78
77 // Get a semblance of coverage for both extension and app settings by 79 // Get a semblance of coverage for both extension and app settings by
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const std::string id = "ext"; 187 const std::string id = "ext";
186 scoped_refptr<const Extension> extension = 188 scoped_refptr<const Extension> extension =
187 util::AddExtensionWithId(browser_context(), id, Manifest::TYPE_EXTENSION); 189 util::AddExtensionWithId(browser_context(), id, Manifest::TYPE_EXTENSION);
188 190
189 ValueStore* sync_storage = 191 ValueStore* sync_storage =
190 util::GetStorage(extension, settings::SYNC, frontend_.get()); 192 util::GetStorage(extension, settings::SYNC, frontend_.get());
191 ValueStore* local_storage = 193 ValueStore* local_storage =
192 util::GetStorage(extension, settings::LOCAL, frontend_.get()); 194 util::GetStorage(extension, settings::LOCAL, frontend_.get());
193 195
194 // Sync storage should run out after ~100K. 196 // Sync storage should run out after ~100K.
195 scoped_ptr<base::Value> kilobyte = util::CreateKilobyte(); 197 std::unique_ptr<base::Value> kilobyte = util::CreateKilobyte();
196 for (int i = 0; i < 100; ++i) { 198 for (int i = 0; i < 100; ++i) {
197 sync_storage->Set(DEFAULTS, base::IntToString(i), *kilobyte); 199 sync_storage->Set(DEFAULTS, base::IntToString(i), *kilobyte);
198 } 200 }
199 201
200 EXPECT_FALSE( 202 EXPECT_FALSE(
201 sync_storage->Set(DEFAULTS, "WillError", *kilobyte)->status().ok()); 203 sync_storage->Set(DEFAULTS, "WillError", *kilobyte)->status().ok());
202 204
203 // Local storage shouldn't run out after ~100K. 205 // Local storage shouldn't run out after ~100K.
204 for (int i = 0; i < 100; ++i) { 206 for (int i = 0; i < 100; ++i) {
205 local_storage->Set(DEFAULTS, base::IntToString(i), *kilobyte); 207 local_storage->Set(DEFAULTS, base::IntToString(i), *kilobyte);
206 } 208 }
207 209
208 EXPECT_TRUE( 210 EXPECT_TRUE(
209 local_storage->Set(DEFAULTS, "WontError", *kilobyte)->status().ok()); 211 local_storage->Set(DEFAULTS, "WontError", *kilobyte)->status().ok());
210 212
211 // Local storage should run out after ~5MB. 213 // Local storage should run out after ~5MB.
212 scoped_ptr<base::Value> megabyte = util::CreateMegabyte(); 214 std::unique_ptr<base::Value> megabyte = util::CreateMegabyte();
213 for (int i = 0; i < 5; ++i) { 215 for (int i = 0; i < 5; ++i) {
214 local_storage->Set(DEFAULTS, base::IntToString(i), *megabyte); 216 local_storage->Set(DEFAULTS, base::IntToString(i), *megabyte);
215 } 217 }
216 218
217 EXPECT_FALSE( 219 EXPECT_FALSE(
218 local_storage->Set(DEFAULTS, "WillError", *megabyte)->status().ok()); 220 local_storage->Set(DEFAULTS, "WillError", *megabyte)->status().ok());
219 } 221 }
220 222
221 } // namespace extensions 223 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/storage/storage_frontend.cc ('k') | extensions/browser/api/system_cpu/cpu_info_provider_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698