Chromium Code Reviews| Index: extensions/browser/api/storage/settings_test_util.cc |
| diff --git a/extensions/browser/api/storage/settings_test_util.cc b/extensions/browser/api/storage/settings_test_util.cc |
| index c1ac66089cd9a0b11df6487e7b7e0105e31404f1..b5142f0889c9f80ec21ef70818ffdf5fa14f73fb 100644 |
| --- a/extensions/browser/api/storage/settings_test_util.cc |
| +++ b/extensions/browser/api/storage/settings_test_util.cc |
| @@ -16,6 +16,24 @@ namespace extensions { |
| namespace settings_test_util { |
| +// Creates a kilobyte of data. |
| +scoped_ptr<base::Value> CreateKilobyte() { |
| + std::string kilobyte_string; |
| + for (int i = 0; i < 1024; ++i) { |
| + kilobyte_string += "a"; |
| + } |
| + return scoped_ptr<base::Value>(new base::StringValue(kilobyte_string)); |
| +} |
| + |
| +// Creates a megabyte of data. |
| +scoped_ptr<base::Value> CreateMegabyte() { |
| + base::ListValue* megabyte = new base::ListValue(); |
| + for (int i = 0; i < 1000; ++i) { |
|
Ken Rockot(use gerrit already)
2014/08/17 21:28:27
I hate to be that guy, but this isn't a megabyte!
Yoyo Zhou
2014/08/17 21:45:28
I noticed too!
not at google - send to devlin
2014/08/18 20:01:24
My bad. It's half way between a real and a bizarro
|
| + megabyte->Append(CreateKilobyte().release()); |
| + } |
| + return scoped_ptr<base::Value>(megabyte); |
| +} |
| + |
| // Intended as a StorageCallback from GetStorage. |
| static void AssignStorage(ValueStore** dst, ValueStore* src) { |
| *dst = src; |
| @@ -36,15 +54,16 @@ ValueStore* GetStorage(scoped_refptr<const Extension> extension, |
| return GetStorage(extension, settings_namespace::SYNC, frontend); |
| } |
| -scoped_refptr<const Extension> AddExtensionWithId(Profile* profile, |
| - const std::string& id, |
| - Manifest::Type type) { |
| +scoped_refptr<const Extension> AddExtensionWithId( |
| + content::BrowserContext* context, |
| + const std::string& id, |
| + Manifest::Type type) { |
| return AddExtensionWithIdAndPermissions( |
| - profile, id, type, std::set<std::string>()); |
| + context, id, type, std::set<std::string>()); |
| } |
| scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( |
| - Profile* profile, |
| + content::BrowserContext* context, |
| const std::string& id, |
| Manifest::Type type, |
| const std::set<std::string>& permissions_set) { |
| @@ -89,7 +108,7 @@ scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( |
| // Ensure lookups via ExtensionRegistry (and ExtensionService) work even if |
| // the test discards the referenced to the returned extension. |
| - ExtensionRegistry::Get(profile)->AddEnabled(extension); |
| + ExtensionRegistry::Get(context)->AddEnabled(extension); |
| for (std::set<std::string>::const_iterator it = permissions_set.begin(); |
| it != permissions_set.end(); ++it) { |
| @@ -99,32 +118,26 @@ scoped_refptr<const Extension> AddExtensionWithIdAndPermissions( |
| return extension; |
| } |
| -// MockExtensionSystem |
| +// MockExtensionSystemWithEventRouter |
| -MockExtensionSystem::MockExtensionSystem(Profile* profile) |
| - : TestExtensionSystem(profile) {} |
| -MockExtensionSystem::~MockExtensionSystem() {} |
| - |
| -EventRouter* MockExtensionSystem::event_router() { |
| - if (!event_router_.get()) |
| - event_router_.reset(new EventRouter(profile_, NULL)); |
| - return event_router_.get(); |
| +MockExtensionSystemWithEventRouter::MockExtensionSystemWithEventRouter( |
| + content::BrowserContext* context) |
| + : MockExtensionSystem(context) { |
| } |
| -KeyedService* BuildMockExtensionSystem(content::BrowserContext* profile) { |
| - return new MockExtensionSystem(static_cast<Profile*>(profile)); |
| +MockExtensionSystemWithEventRouter::~MockExtensionSystemWithEventRouter() { |
| } |
| -// MockProfile |
| - |
| -MockProfile::MockProfile(const base::FilePath& file_path) |
| - : TestingProfile(file_path) { |
| - ExtensionsBrowserClient::Get() |
| - ->GetExtensionSystemFactory() |
| - ->SetTestingFactoryAndUse(this, &BuildMockExtensionSystem); |
| +KeyedService* MockExtensionSystemWithEventRouter::Build( |
| + content::BrowserContext* context) { |
| + return new MockExtensionSystemWithEventRouter(context); |
| } |
| -MockProfile::~MockProfile() {} |
| +EventRouter* MockExtensionSystemWithEventRouter::event_router() { |
| + if (!event_router_.get()) |
| + event_router_.reset(new EventRouter(browser_context(), NULL)); |
| + return event_router_.get(); |
| +} |
| // ScopedSettingsFactory |