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

Side by Side Diff: extensions/browser/api/execute_code_function.h

Issue 2301713002: Remove some UI->FILE->UI thread hops in ExecuteCodeFunction (Closed)
Patch Set: git cl format Created 4 years, 3 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_API_EXECUTE_CODE_FUNCTION_H_ 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "extensions/browser/extension_function.h" 9 #include "extensions/browser/extension_function.h"
10 #include "extensions/browser/script_executor.h" 10 #include "extensions/browser/script_executor.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 bool success, 45 bool success,
46 std::unique_ptr<std::string> data); 46 std::unique_ptr<std::string> data);
47 47
48 const HostID& host_id() const { return host_id_; } 48 const HostID& host_id() const { return host_id_; }
49 void set_host_id(const HostID& host_id) { host_id_ = host_id; } 49 void set_host_id(const HostID& host_id) { host_id_ = host_id; }
50 50
51 // The injection details. 51 // The injection details.
52 std::unique_ptr<api::extension_types::InjectDetails> details_; 52 std::unique_ptr<api::extension_types::InjectDetails> details_;
53 53
54 private: 54 private:
55 // Called when contents from the file whose path is specified in JSON 55 // Retrieves the file url for the given |extension_path| and optionally
56 // arguments has been loaded. 56 // localizes |data|.
57 void DidLoadFile(bool success, std::unique_ptr<std::string> data); 57 // Localization depends on whether |might_require_localization| was specified.
58 // Only CSS file content needs to be localized.
59 void GetFileURLAndMaybeLocalizeOnFileThread(
60 const std::string& extension_id,
61 const base::FilePath& extension_path,
62 const std::string& extension_default_locale,
63 bool might_require_localization,
64 std::string* data);
58 65
59 // Runs on FILE thread. Loads message bundles for the extension and 66 void GetFileURLAndLocalizeComponentResourceOnFileThread(
Devlin 2016/09/01 06:15:21 nit: a brief comment documenting this would be goo
lazyboy 2016/09/01 18:10:18 Done.
60 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. 67 std::unique_ptr<std::string> data,
61 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type, 68 bool might_require_localization,
62 std::unique_ptr<std::string> data, 69 const std::string& extension_id,
63 const std::string& extension_id, 70 const base::FilePath& extension_path,
64 const base::FilePath& extension_path, 71 const std::string& extension_default_locale);
65 const std::string& extension_default_locale);
66 72
67 // Run in UI thread. Code string contains the code to be executed. Returns 73 // Run in UI thread. Code string contains the code to be executed. Returns
68 // true on success. If true is returned, this does an AddRef. 74 // true on success. If true is returned, this does an AddRef.
69 bool Execute(const std::string& code_string); 75 bool Execute(const std::string& code_string);
70 76
71 // Contains extension resource built from path of file which is 77 // Contains extension resource built from path of file which is
72 // specified in JSON arguments. 78 // specified in JSON arguments.
73 ExtensionResource resource_; 79 ExtensionResource resource_;
74 80
75 // The URL of the file being injected into the page. 81 // The URL of the file being injected into the page.
76 GURL file_url_; 82 GURL file_url_;
77 83
78 // The ID of the injection host. 84 // The ID of the injection host.
79 HostID host_id_; 85 HostID host_id_;
80 86
81 DISALLOW_COPY_AND_ASSIGN(ExecuteCodeFunction); 87 DISALLOW_COPY_AND_ASSIGN(ExecuteCodeFunction);
82 }; 88 };
83 89
84 } // namespace extensions 90 } // namespace extensions
85 91
86 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 92 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698