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

Side by Side Diff: extensions/browser/api/storage/settings_test_util.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/settings_test_util.h" 5 #include "extensions/browser/api/storage/settings_test_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "extensions/browser/api/storage/storage_frontend.h" 8 #include "extensions/browser/api/storage/storage_frontend.h"
9 #include "extensions/browser/extension_registry.h" 9 #include "extensions/browser/extension_registry.h"
10 #include "extensions/browser/extension_system_provider.h" 10 #include "extensions/browser/extension_system_provider.h"
11 #include "extensions/browser/extensions_browser_client.h" 11 #include "extensions/browser/extensions_browser_client.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "extensions/common/permissions/permissions_data.h" 13 #include "extensions/common/permissions/permissions_data.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 namespace settings_test_util { 17 namespace settings_test_util {
18 18
19 // Creates a kilobyte of data. 19 // Creates a kilobyte of data.
20 scoped_ptr<base::Value> CreateKilobyte() { 20 std::unique_ptr<base::Value> CreateKilobyte() {
21 std::string kilobyte_string; 21 std::string kilobyte_string;
22 for (int i = 0; i < 1024; ++i) { 22 for (int i = 0; i < 1024; ++i) {
23 kilobyte_string += "a"; 23 kilobyte_string += "a";
24 } 24 }
25 return scoped_ptr<base::Value>(new base::StringValue(kilobyte_string)); 25 return std::unique_ptr<base::Value>(new base::StringValue(kilobyte_string));
26 } 26 }
27 27
28 // Creates a megabyte of data. 28 // Creates a megabyte of data.
29 scoped_ptr<base::Value> CreateMegabyte() { 29 std::unique_ptr<base::Value> CreateMegabyte() {
30 base::ListValue* megabyte = new base::ListValue(); 30 base::ListValue* megabyte = new base::ListValue();
31 for (int i = 0; i < 1000; ++i) { 31 for (int i = 0; i < 1000; ++i) {
32 megabyte->Append(CreateKilobyte().release()); 32 megabyte->Append(CreateKilobyte().release());
33 } 33 }
34 return scoped_ptr<base::Value>(megabyte); 34 return std::unique_ptr<base::Value>(megabyte);
35 } 35 }
36 36
37 // Intended as a StorageCallback from GetStorage. 37 // Intended as a StorageCallback from GetStorage.
38 static void AssignStorage(ValueStore** dst, ValueStore* src) { 38 static void AssignStorage(ValueStore** dst, ValueStore* src) {
39 *dst = src; 39 *dst = src;
40 } 40 }
41 41
42 ValueStore* GetStorage(scoped_refptr<const Extension> extension, 42 ValueStore* GetStorage(scoped_refptr<const Extension> extension,
43 settings_namespace::Namespace settings_namespace, 43 settings_namespace::Namespace settings_namespace,
44 StorageFrontend* frontend) { 44 StorageFrontend* frontend) {
(...skipping 19 matching lines...) Expand all
64 64
65 scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( 65 scoped_refptr<const Extension> AddExtensionWithIdAndPermissions(
66 content::BrowserContext* context, 66 content::BrowserContext* context,
67 const std::string& id, 67 const std::string& id,
68 Manifest::Type type, 68 Manifest::Type type,
69 const std::set<std::string>& permissions_set) { 69 const std::set<std::string>& permissions_set) {
70 base::DictionaryValue manifest; 70 base::DictionaryValue manifest;
71 manifest.SetString("name", std::string("Test extension ") + id); 71 manifest.SetString("name", std::string("Test extension ") + id);
72 manifest.SetString("version", "1.0"); 72 manifest.SetString("version", "1.0");
73 73
74 scoped_ptr<base::ListValue> permissions(new base::ListValue()); 74 std::unique_ptr<base::ListValue> permissions(new base::ListValue());
75 for (std::set<std::string>::const_iterator it = permissions_set.begin(); 75 for (std::set<std::string>::const_iterator it = permissions_set.begin();
76 it != permissions_set.end(); ++it) { 76 it != permissions_set.end(); ++it) {
77 permissions->Append(new base::StringValue(*it)); 77 permissions->Append(new base::StringValue(*it));
78 } 78 }
79 manifest.Set("permissions", permissions.release()); 79 manifest.Set("permissions", permissions.release());
80 80
81 switch (type) { 81 switch (type) {
82 case Manifest::TYPE_EXTENSION: 82 case Manifest::TYPE_EXTENSION:
83 break; 83 break;
84 84
(...skipping 29 matching lines...) Expand all
114 it != permissions_set.end(); ++it) { 114 it != permissions_set.end(); ++it) {
115 DCHECK(extension->permissions_data()->HasAPIPermission(*it)); 115 DCHECK(extension->permissions_data()->HasAPIPermission(*it));
116 } 116 }
117 117
118 return extension; 118 return extension;
119 } 119 }
120 120
121 } // namespace settings_test_util 121 } // namespace settings_test_util
122 122
123 } // namespace extensions 123 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/storage/settings_test_util.h ('k') | extensions/browser/api/storage/storage_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698