Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / extensions / test_extension_system.h
blob4a06463bb955779e34bb1ed44645271287cbed29
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_
8 #include "base/memory/scoped_vector.h"
9 #include "extensions/browser/extension_system.h"
10 #include "extensions/common/one_shot_event.h"
12 class Profile;
13 class TestingValueStore;
15 namespace base {
16 class CommandLine;
17 class FilePath;
18 class Time;
21 namespace content {
22 class BrowserContext;
25 namespace extensions {
26 class DeclarativeUserScriptMaster;
27 class ExtensionPrefs;
28 class RuntimeData;
29 class SharedUserScriptMaster;
30 class StandardManagementPolicyProvider;
32 // Test ExtensionSystem, for use with TestingProfile.
33 class TestExtensionSystem : public ExtensionSystem {
34 public:
35 explicit TestExtensionSystem(Profile* profile);
36 virtual ~TestExtensionSystem();
38 // KeyedService implementation.
39 virtual void Shutdown() override;
41 // Creates an ExtensionPrefs with the testing profile and returns it.
42 // Useful for tests that need to modify prefs before creating the
43 // ExtensionService.
44 ExtensionPrefs* CreateExtensionPrefs(const base::CommandLine* command_line,
45 const base::FilePath& install_directory);
47 // Creates an ExtensionService initialized with the testing profile and
48 // returns it, and creates ExtensionPrefs if it hasn't been created yet.
49 ExtensionService* CreateExtensionService(
50 const base::CommandLine* command_line,
51 const base::FilePath& install_directory,
52 bool autoupdate_enabled);
54 // Creates a ProcessManager. If not invoked, the ProcessManager is NULL.
55 void CreateProcessManager();
57 // Allows the ProcessManager to be overriden, for example by a stub
58 // implementation. Takes ownership of |manager|.
59 void SetProcessManager(ProcessManager* manager);
61 void CreateSocketManager();
63 virtual void InitForRegularProfile(bool extensions_enabled) override {}
64 void SetExtensionService(ExtensionService* service);
65 virtual ExtensionService* extension_service() override;
66 virtual RuntimeData* runtime_data() override;
67 virtual ManagementPolicy* management_policy() override;
68 virtual SharedUserScriptMaster* shared_user_script_master() override;
69 virtual ProcessManager* process_manager() override;
70 virtual StateStore* state_store() override;
71 virtual StateStore* rules_store() override;
72 TestingValueStore* value_store() { return value_store_; }
73 virtual InfoMap* info_map() override;
74 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() override;
75 void SetEventRouter(scoped_ptr<EventRouter> event_router);
76 virtual EventRouter* event_router() override;
77 virtual WarningService* warning_service() override;
78 virtual Blacklist* blacklist() override;
79 virtual ErrorConsole* error_console() override;
80 virtual InstallVerifier* install_verifier() override;
81 virtual QuotaService* quota_service() override;
82 virtual const OneShotEvent& ready() const override;
83 virtual ContentVerifier* content_verifier() override;
84 virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
85 const Extension* extension) override;
86 virtual DeclarativeUserScriptMaster*
87 GetDeclarativeUserScriptMasterByExtension(
88 const ExtensionId& extension_id) override;
90 // Note that you probably want to use base::RunLoop().RunUntilIdle() right
91 // after this to run all the accumulated tasks.
92 void SetReady() { ready_.Signal(); }
94 // Factory method for tests to use with SetTestingProfile.
95 static KeyedService* Build(content::BrowserContext* profile);
97 protected:
98 Profile* profile_;
100 private:
101 scoped_ptr<StateStore> state_store_;
102 // A pointer to the TestingValueStore owned by |state_store_|.
103 TestingValueStore* value_store_;
104 ScopedVector<DeclarativeUserScriptMaster> declarative_user_script_masters_;
105 scoped_ptr<Blacklist> blacklist_;
106 scoped_ptr<ManagementPolicy> management_policy_;
107 scoped_ptr<RuntimeData> runtime_data_;
108 scoped_ptr<ExtensionService> extension_service_;
109 scoped_ptr<ProcessManager> process_manager_;
110 scoped_refptr<InfoMap> info_map_;
111 scoped_ptr<EventRouter> event_router_;
112 scoped_ptr<ErrorConsole> error_console_;
113 scoped_ptr<InstallVerifier> install_verifier_;
114 scoped_ptr<QuotaService> quota_service_;
115 OneShotEvent ready_;
118 } // namespace extensions
120 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_SYSTEM_H_