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

Side by Side Diff: extensions/browser/declarative_user_script_master.h

Issue 2228743002: Rework some UserScriptLoader logic in preparation to removing UserScript copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott Created 4 years, 4 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 #ifndef EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ 5 #ifndef EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ 6 #define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
13 #include "extensions/common/host_id.h" 13 #include "extensions/common/host_id.h"
14 14
15 namespace content { 15 namespace content {
16 class BrowserContext; 16 class BrowserContext;
17 } 17 }
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 class UserScript; 21 class UserScript;
22 class UserScriptLoader; 22 class UserScriptLoader;
23 23
24 struct UserScriptIDPair;
25
24 // Manages declarative user scripts for a single extension. Owns a 26 // Manages declarative user scripts for a single extension. Owns a
25 // UserScriptLoader to which file loading and shared memory management 27 // UserScriptLoader to which file loading and shared memory management
26 // operations are delegated, and provides an interface for adding, removing, 28 // operations are delegated, and provides an interface for adding, removing,
27 // and clearing scripts. 29 // and clearing scripts.
28 class DeclarativeUserScriptMaster { 30 class DeclarativeUserScriptMaster {
29 public: 31 public:
30 DeclarativeUserScriptMaster(content::BrowserContext* browser_context, 32 DeclarativeUserScriptMaster(content::BrowserContext* browser_context,
31 const HostID& host_id); 33 const HostID& host_id);
32 ~DeclarativeUserScriptMaster(); 34 ~DeclarativeUserScriptMaster();
33 35
34 // Adds script to shared memory region. This may not happen right away if a 36 // Adds script to shared memory region. This may not happen right away if a
35 // script load is in progress. 37 // script load is in progress.
36 void AddScript(const UserScript& script); 38 void AddScript(const UserScript& script);
37 39
38 // Adds a set of scripts to shared meomory region. The fetch of the content 40 // Adds a set of scripts to shared meomory region. The fetch of the content
39 // of the script on WebUI requires to start URL request to the associated 41 // of the script on WebUI requires to start URL request to the associated
40 // render specified by |render_process_id, render_frame_id|. 42 // render specified by |render_process_id, render_frame_id|.
41 // This may not happen right away if a script load is in progress. 43 // This may not happen right away if a script load is in progress.
42 void AddScripts(const std::set<UserScript>& scripts, 44 void AddScripts(const std::vector<UserScript>& scripts,
43 int render_process_id, 45 int render_process_id,
44 int render_frame_id); 46 int render_frame_id);
45 47
46 // Removes script from shared memory region. This may not happen right away if 48 // Removes script from shared memory region. This may not happen right away if
47 // a script load is in progress. 49 // a script load is in progress.
48 void RemoveScript(const UserScript& script); 50 void RemoveScript(const UserScript& script);
49 51
50 // Removes a set of scripts from shared memory region. This may not happen 52 // Removes a set of scripts from shared memory region. This may not happen
51 // right away if a script load is in progress. 53 // right away if a script load is in progress.
52 void RemoveScripts(const std::set<UserScript>& scripts); 54 void RemoveScripts(const std::set<UserScriptIDPair>& scripts);
53 55
54 // Removes all scripts from shared memory region. This may not happen right 56 // Removes all scripts from shared memory region. This may not happen right
55 // away if a script load is in progress. 57 // away if a script load is in progress.
56 void ClearScripts(); 58 void ClearScripts();
57 59
58 const HostID& host_id() const { return host_id_; } 60 const HostID& host_id() const { return host_id_; }
59 61
60 UserScriptLoader* loader() { return loader_.get(); } 62 UserScriptLoader* loader() { return loader_.get(); }
61 63
62 private: 64 private:
63 // ID of host that owns scripts that this component manages. 65 // ID of host that owns scripts that this component manages.
64 HostID host_id_; 66 HostID host_id_;
65 67
66 // Script loader that handles loading contents of scripts into shared memory 68 // Script loader that handles loading contents of scripts into shared memory
67 // and notifying renderers of script updates. 69 // and notifying renderers of script updates.
68 std::unique_ptr<UserScriptLoader> loader_; 70 std::unique_ptr<UserScriptLoader> loader_;
69 71
70 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); 72 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster);
71 }; 73 };
72 74
73 } // namespace extensions 75 } // namespace extensions
74 76
75 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_ 77 #endif // EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698