Chromium Code Reviews| 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 // WebViewRendererState manages state data for WebView guest renderer processes. | 5 // WebViewRendererState manages state data for WebView guest renderer processes. |
| 6 // | 6 // |
| 7 // This class's data can be accessed via its methods from both the UI and IO | 7 // This class's data can be accessed via its methods from both the UI and IO |
| 8 // threads, and uses locks to mediate this access. When making changes to this | 8 // threads, and uses locks to mediate this access. When making changes to this |
| 9 // class, ensure that you avoid introducing any reentrant code in the methods, | 9 // class, ensure that you avoid introducing any reentrant code in the methods, |
| 10 // and that you always aquire the locks in the order |web_view_info_map_lock_| | 10 // and that you always aquire the locks in the order |web_view_info_map_lock_| |
| 11 // -> |web_view_partition_id_map_lock_| (if both are needed in one method). | 11 // -> |web_view_partition_id_map_lock_| (if both are needed in one method). |
| 12 | 12 |
| 13 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ | 13 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ |
| 14 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ | 14 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 #include <set> | 17 #include <set> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <utility> | 19 #include <utility> |
| 20 | 20 |
| 21 #include "base/memory/singleton.h" | 21 #include "base/memory/singleton.h" |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 | 24 |
| 25 class WebViewGuest; | 25 class WebViewGuest; |
| 26 | 26 |
| 27 // This class keeps track of <webview> renderer state for use on the IO thread. | |
| 28 // All methods should be called on the IO thread. | |
|
not at google - send to devlin
2015/09/03 20:17:54
You might actually want to keep a comment, just ha
paulmeyer
2015/09/08 18:51:36
I removed this comment because the same info is al
| |
| 29 class WebViewRendererState { | 27 class WebViewRendererState { |
| 30 public: | 28 public: |
| 31 struct WebViewInfo { | 29 struct WebViewInfo { |
| 32 int embedder_process_id; | 30 int embedder_process_id; |
| 33 int instance_id; | 31 int instance_id; |
| 34 int rules_registry_id; | 32 int rules_registry_id; |
| 35 std::string partition_id; | 33 std::string partition_id; |
| 36 std::string owner_host; | 34 std::string owner_host; |
| 37 std::set<int> content_script_ids; | 35 std::set<int> content_script_ids; |
| 38 | 36 |
| 39 WebViewInfo(); | 37 WebViewInfo(); |
| 40 ~WebViewInfo(); | 38 ~WebViewInfo(); |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 static WebViewRendererState* GetInstance(); | 41 static WebViewRendererState* GetInstance(); |
| 44 | 42 |
| 45 // Looks up the information for the embedder <webview> for a given render | 43 // Looks up the information for the embedder <webview> for a given render |
|
not at google - send to devlin
2015/09/03 20:17:54
I don't like the way these comments (for all funct
paulmeyer
2015/09/08 18:51:36
Updated the comments.
| |
| 46 // view, if one exists. Called on the IO thread. | 44 // view, if one exists. |
| 47 bool GetInfo(int guest_process_id, | 45 bool GetInfo(int guest_process_id, |
| 48 int guest_routing_id, | 46 int guest_routing_id, |
| 49 WebViewInfo* web_view_info) const; | 47 WebViewInfo* web_view_info) const; |
| 50 | 48 |
| 51 // Looks up the information for the owner for a given guest process in a | 49 // Looks up the information for the owner for a given guest process in a |
| 52 // <webview>. Called on the IO thread. | 50 // <webview>. |
| 53 bool GetOwnerInfo(int guest_process_id, | 51 bool GetOwnerInfo(int guest_process_id, |
| 54 int* owner_process_id, | 52 int* owner_process_id, |
| 55 std::string* owner_host) const; | 53 std::string* owner_host) const; |
| 56 | 54 |
| 57 // Looks up the partition info for the embedder <webview> for a given guest | 55 // Looks up the partition info for the embedder <webview> for a given guest |
| 58 // process. Called on the IO thread. | 56 // process. |
| 59 bool GetPartitionID(int guest_process_id, std::string* partition_id) const; | 57 bool GetPartitionID(int guest_process_id, std::string* partition_id) const; |
| 60 | 58 |
| 61 // Returns true if the given renderer is used by webviews. | 59 // Returns true if the given renderer is used by webviews. |
| 62 bool IsGuest(int render_process_id) const; | 60 bool IsGuest(int render_process_id) const; |
| 63 | 61 |
| 64 void AddContentScriptIDs(int embedder_process_id, | 62 void AddContentScriptIDs(int embedder_process_id, |
| 65 int view_instance_id, | 63 int view_instance_id, |
| 66 const std::set<int>& script_ids); | 64 const std::set<int>& script_ids); |
| 67 void RemoveContentScriptIDs(int embedder_process_id, | 65 void RemoveContentScriptIDs(int embedder_process_id, |
| 68 int view_instance_id, | 66 int view_instance_id, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 mutable base::Lock web_view_info_map_lock_; | 98 mutable base::Lock web_view_info_map_lock_; |
| 101 WebViewPartitionIDMap web_view_partition_id_map_; | 99 WebViewPartitionIDMap web_view_partition_id_map_; |
| 102 mutable base::Lock web_view_partition_id_map_lock_; | 100 mutable base::Lock web_view_partition_id_map_lock_; |
| 103 | 101 |
| 104 DISALLOW_COPY_AND_ASSIGN(WebViewRendererState); | 102 DISALLOW_COPY_AND_ASSIGN(WebViewRendererState); |
| 105 }; | 103 }; |
| 106 | 104 |
| 107 } // namespace extensions | 105 } // namespace extensions |
| 108 | 106 |
| 109 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ | 107 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_RENDERER_STATE_H_ |
| OLD | NEW |