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

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

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
9 #include "content/public/test/test_browser_context.h" 10 #include "content/public/test/test_browser_context.h"
10 #include "extensions/browser/api/extensions_api_client.h" 11 #include "extensions/browser/api/extensions_api_client.h"
11 #include "extensions/browser/api/storage/leveldb_settings_storage_factory.h" 12 #include "extensions/browser/api/storage/leveldb_settings_storage_factory.h"
12 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" 13 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
13 #include "extensions/browser/api/storage/settings_test_util.h" 14 #include "extensions/browser/api/storage/settings_test_util.h"
14 #include "extensions/browser/api/storage/storage_api.h" 15 #include "extensions/browser/api/storage/storage_api.h"
15 #include "extensions/browser/api/storage/storage_frontend.h" 16 #include "extensions/browser/api/storage/storage_frontend.h"
16 #include "extensions/browser/api_unittest.h" 17 #include "extensions/browser/api_unittest.h"
17 #include "extensions/browser/event_router.h" 18 #include "extensions/browser/event_router.h"
18 #include "extensions/browser/event_router_factory.h" 19 #include "extensions/browser/event_router_factory.h"
19 #include "extensions/browser/test_extensions_browser_client.h" 20 #include "extensions/browser/test_extensions_browser_client.h"
20 #include "extensions/browser/value_store/leveldb_value_store.h" 21 #include "extensions/browser/value_store/leveldb_value_store.h"
21 #include "extensions/browser/value_store/value_store.h" 22 #include "extensions/browser/value_store/value_store.h"
22 #include "extensions/common/manifest.h" 23 #include "extensions/common/manifest.h"
23 #include "extensions/common/test_util.h" 24 #include "extensions/common/test_util.h"
24 #include "third_party/leveldatabase/src/include/leveldb/db.h" 25 #include "third_party/leveldatabase/src/include/leveldb/db.h"
25 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 26 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
26 27
27 namespace extensions { 28 namespace extensions {
28 29
29 namespace { 30 namespace {
30 31
31 // Caller owns the returned object. 32 // Caller owns the returned object.
32 KeyedService* CreateStorageFrontendForTesting( 33 scoped_ptr<KeyedService> CreateStorageFrontendForTesting(
33 content::BrowserContext* context) { 34 content::BrowserContext* context) {
34 return StorageFrontend::CreateForTesting(new LeveldbSettingsStorageFactory(), 35 return StorageFrontend::CreateForTesting(new LeveldbSettingsStorageFactory(),
35 context); 36 context);
36 } 37 }
37 38
38 KeyedService* BuildEventRouter(content::BrowserContext* profile) { 39 scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* profile) {
Devlin 2015/06/08 19:29:43 nit: rename
Ilya Sherman 2015/06/08 22:11:43 Done.
39 return new extensions::EventRouter(profile, nullptr); 40 return make_scoped_ptr(new extensions::EventRouter(profile, nullptr));
40 } 41 }
41 42
42 } // namespace 43 } // namespace
43 44
44 class StorageApiUnittest : public ApiUnitTest { 45 class StorageApiUnittest : public ApiUnitTest {
45 public: 46 public:
46 StorageApiUnittest() {} 47 StorageApiUnittest() {}
47 ~StorageApiUnittest() override {} 48 ~StorageApiUnittest() override {}
48 49
49 protected: 50 protected:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 EXPECT_TRUE(leveldb_store->Get(kKey)->IsCorrupted()); 114 EXPECT_TRUE(leveldb_store->Get(kKey)->IsCorrupted());
114 115
115 // Running another set should end up working (even though it will restore the 116 // Running another set should end up working (even though it will restore the
116 // store behind the scenes). 117 // store behind the scenes).
117 RunSetFunction(kKey, kValue); 118 RunSetFunction(kKey, kValue);
118 EXPECT_TRUE(RunGetFunction(kKey, &result)); 119 EXPECT_TRUE(RunGetFunction(kKey, &result));
119 EXPECT_EQ(kValue, result); 120 EXPECT_EQ(kValue, result);
120 } 121 }
121 122
122 } // namespace extensions 123 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698