| OLD | NEW |
| 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 #ifndef EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ | 5 #ifndef EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ |
| 6 #define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ | 6 #define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Manages one "logical unit" of user scripts in shared memory by constructing a | 35 // Manages one "logical unit" of user scripts in shared memory by constructing a |
| 36 // new shared memory region when the set of scripts changes. Also notifies | 36 // new shared memory region when the set of scripts changes. Also notifies |
| 37 // renderers of new shared memory region when new renderers appear, or when | 37 // renderers of new shared memory region when new renderers appear, or when |
| 38 // script reloading completes. Script loading lives on the UI thread. Instances | 38 // script reloading completes. Script loading lives on the UI thread. Instances |
| 39 // of this class are embedded within classes with names ending in | 39 // of this class are embedded within classes with names ending in |
| 40 // UserScriptMaster. These "master" classes implement the strategy for which | 40 // UserScriptMaster. These "master" classes implement the strategy for which |
| 41 // scripts to load/unload on this logical unit of scripts. | 41 // scripts to load/unload on this logical unit of scripts. |
| 42 class UserScriptLoader : public content::NotificationObserver { | 42 class UserScriptLoader : public content::NotificationObserver { |
| 43 public: | 43 public: |
| 44 using LoadScriptsCallback = | 44 using LoadScriptsCallback = |
| 45 base::Callback<void(std::unique_ptr<UserScriptList>, | 45 base::OnceCallback<void(std::unique_ptr<UserScriptList>, |
| 46 std::unique_ptr<base::SharedMemory>)>; | 46 std::unique_ptr<base::SharedMemory>)>; |
| 47 class Observer { | 47 class Observer { |
| 48 public: | 48 public: |
| 49 virtual void OnScriptsLoaded(UserScriptLoader* loader) = 0; | 49 virtual void OnScriptsLoaded(UserScriptLoader* loader) = 0; |
| 50 virtual void OnUserScriptLoaderDestroyed(UserScriptLoader* loader) = 0; | 50 virtual void OnUserScriptLoaderDestroyed(UserScriptLoader* loader) = 0; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // Parses the includes out of |script| and returns them in |includes|. | 53 // Parses the includes out of |script| and returns them in |includes|. |
| 54 static bool ParseMetadataHeader(const base::StringPiece& script_text, | 54 static bool ParseMetadataHeader(const base::StringPiece& script_text, |
| 55 UserScript* script); | 55 UserScript* script); |
| 56 | 56 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 base::ObserverList<Observer> observers_; | 181 base::ObserverList<Observer> observers_; |
| 182 | 182 |
| 183 base::WeakPtrFactory<UserScriptLoader> weak_factory_; | 183 base::WeakPtrFactory<UserScriptLoader> weak_factory_; |
| 184 | 184 |
| 185 DISALLOW_COPY_AND_ASSIGN(UserScriptLoader); | 185 DISALLOW_COPY_AND_ASSIGN(UserScriptLoader); |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 } // namespace extensions | 188 } // namespace extensions |
| 189 | 189 |
| 190 #endif // EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ | 190 #endif // EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_ |
| OLD | NEW |