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

Unified Diff: extensions/browser/user_script_loader.h

Issue 2227193002: Make UserScript non-copyable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: uplaod with base 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/user_script_loader.h
diff --git a/extensions/browser/user_script_loader.h b/extensions/browser/user_script_loader.h
index 9267970b151c273038160d1e2334d5879023cca5..98eef932efb4751e0d35cd4cdeb01aa4fbcdd552 100644
--- a/extensions/browser/user_script_loader.h
+++ b/extensions/browser/user_script_loader.h
@@ -17,6 +17,7 @@
#include "base/scoped_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/browser_user_script.h"
#include "extensions/common/host_id.h"
#include "extensions/common/user_script.h"
@@ -31,6 +32,8 @@ class RenderProcessHost;
namespace extensions {
+class BrowserUserScript;
+
// Manages one "logical unit" of user scripts in shared memory by constructing a
// new shared memory region when the set of scripts changes. Also notifies
// renderers of new shared memory region when new renderers appear, or when
@@ -40,9 +43,9 @@ namespace extensions {
// scripts to load/unload on this logical unit of scripts.
class UserScriptLoader : public content::NotificationObserver {
public:
- using LoadScriptsCallback =
- base::Callback<void(std::unique_ptr<UserScriptList>,
- std::unique_ptr<base::SharedMemory>)>;
+ using LoadScriptsCallback = base::Callback<void(
+ std::unique_ptr<std::vector<std::unique_ptr<BrowserUserScript>>>,
+ std::unique_ptr<base::SharedMemory>)>;
class Observer {
public:
virtual void OnScriptsLoaded(UserScriptLoader* loader) = 0;
@@ -51,14 +54,14 @@ class UserScriptLoader : public content::NotificationObserver {
// Parses the includes out of |script| and returns them in |includes|.
static bool ParseMetadataHeader(const base::StringPiece& script_text,
- UserScript* script);
+ BrowserUserScript* script);
UserScriptLoader(content::BrowserContext* browser_context,
const HostID& host_id);
~UserScriptLoader() override;
// Add |scripts| to the set of scripts managed by this loader.
- void AddScripts(const UserScriptList& scripts);
+ void AddScripts(BrowserUserScriptList& scripts);
// Add |scripts| to the set of scripts managed by this loader.
// The fetch of the content of the script starts URL request
@@ -66,7 +69,7 @@ class UserScriptLoader : public content::NotificationObserver {
// |render_process_id, render_view_id|.
// TODO(hanxi): The renderer information doesn't really belong in this base
// class, but it's not an easy fix.
- virtual void AddScripts(const UserScriptList& scripts,
+ virtual void AddScripts(BrowserUserScriptList& scripts,
int render_process_id,
int render_view_id);
@@ -87,7 +90,7 @@ class UserScriptLoader : public content::NotificationObserver {
// Pickle user scripts and return pointer to the shared memory.
static std::unique_ptr<base::SharedMemory> Serialize(
- const extensions::UserScriptList& scripts);
+ const extensions::BrowserUserScriptList& scripts);
// Adds or removes observers.
void AddObserver(Observer* observer);
@@ -95,7 +98,7 @@ class UserScriptLoader : public content::NotificationObserver {
protected:
// Allows the derived classes have different ways to load user scripts.
- virtual void LoadScripts(std::unique_ptr<UserScriptList> user_scripts,
+ virtual void LoadScripts(std::unique_ptr<BrowserUserScriptList> user_scripts,
const std::set<HostID>& changed_hosts,
const std::set<int>& added_script_ids,
LoadScriptsCallback callback) = 0;
@@ -122,7 +125,7 @@ class UserScriptLoader : public content::NotificationObserver {
void AttemptLoad();
// Called once we have finished loading the scripts on the file thread.
- void OnScriptsLoaded(std::unique_ptr<UserScriptList> user_scripts,
+ void OnScriptsLoaded(std::unique_ptr<BrowserUserScriptList> user_scripts,
std::unique_ptr<base::SharedMemory> shared_memory);
// Sends the renderer process a new set of user scripts. If
@@ -145,12 +148,12 @@ class UserScriptLoader : public content::NotificationObserver {
std::unique_ptr<base::SharedMemory> shared_memory_;
// List of scripts from currently-installed extensions we should load.
- std::unique_ptr<UserScriptList> user_scripts_;
+ std::unique_ptr<BrowserUserScriptList> user_scripts_;
// The mutually-exclusive information about sets of scripts that were added or
// removed since the last script load. These maps are keyed by script's id.
// Note that we only need HostID information for removal.
- std::map<int, UserScript> added_scripts_map_;
+ std::map<int, std::unique_ptr<BrowserUserScript>> added_scripts_map_;
std::set<UserScriptIDPair> removed_script_hosts_;
// Indicates whether the the collection of scripts should be cleared before

Powered by Google App Engine
This is Rietveld 408576698