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

Unified Diff: extensions/browser/browser_user_script.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/browser_user_script.h
diff --git a/extensions/browser/browser_user_script.h b/extensions/browser/browser_user_script.h
new file mode 100644
index 0000000000000000000000000000000000000000..df3836d58bcd0c274dd121fa5681b8e49914649c
--- /dev/null
+++ b/extensions/browser/browser_user_script.h
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_BROWSER_USER_SCRIPT_H_
+#define EXTENSIONS_BROWSER_BROWSER_USER_SCRIPT_H_
+
+#include "extensions/common/user_script.h"
+
+namespace base {
+class Pickle;
+}
+
+namespace extensions {
+
+// browser/ process representation of a user script file.
+// Contains the content of the script file, so this is expensive to copy around.
+class BrowserScriptFile : public UserScriptFileInfo {
+ public:
+ BrowserScriptFile(const UserScriptFileInfo& info);
+ BrowserScriptFile(const base::FilePath& extension_root,
+ const base::FilePath& relative_path,
+ const GURL& url);
+ ~BrowserScriptFile() override;
+
+ void set_content(base::StringPiece content) {
+ content_.assign(content.begin(), content.end());
+ }
+ base::StringPiece GetContent() { return content_; }
+
+ private:
+ std::string content_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserScriptFile);
+};
+
+// browser/ process representation of a user script.
+// A user script can contain multiple script files in it. The browser/ process
+// loads these files and then the contents are shared with the renderer/ process
+// via shared memory.
+class BrowserUserScript : public UserScriptInfo,
Devlin 2016/08/11 17:05:54 I'd prefer we avoided having a Browser/Renderer Us
+ public UserScriptFiles<BrowserScriptFile> {
+ public:
+ BrowserUserScript();
+ BrowserUserScript(UserScriptInfo& meta,
+ UserScriptFiles<UserScriptFileInfo>& files);
+ ~BrowserUserScript() override;
+
+ void Pickle(base::Pickle* pickle) const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserUserScript);
+};
+
+using BrowserUserScriptList = std::vector<std::unique_ptr<BrowserUserScript>>;
+using BrowserScriptFileList = std::vector<std::unique_ptr<BrowserScriptFile>>;
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_BROWSER_USER_SCRIPT_H_

Powered by Google App Engine
This is Rietveld 408576698