| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_EXTENSION_API_FRAME_ID_MAP_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // TODO(robwu): Keep an eye on crbug.com/524228 and act upon the outcome. | 41 // TODO(robwu): Keep an eye on crbug.com/524228 and act upon the outcome. |
| 42 class ExtensionApiFrameIdMap { | 42 class ExtensionApiFrameIdMap { |
| 43 public: | 43 public: |
| 44 using FrameIdCallback = | 44 using FrameIdCallback = |
| 45 base::Callback<void(int extension_api_frame_id, | 45 base::Callback<void(int extension_api_frame_id, |
| 46 int extension_api_parent_frame_id)>; | 46 int extension_api_parent_frame_id)>; |
| 47 | 47 |
| 48 // An invalid extension API frame ID. | 48 // An invalid extension API frame ID. |
| 49 static const int kInvalidFrameId; | 49 static const int kInvalidFrameId; |
| 50 | 50 |
| 51 // Extension API frame ID of the top-level frame. |
| 52 static const int kTopFrameId; |
| 53 |
| 51 static ExtensionApiFrameIdMap* Get(); | 54 static ExtensionApiFrameIdMap* Get(); |
| 52 | 55 |
| 53 // Get the extension API frame ID for |rfh|. | 56 // Get the extension API frame ID for |rfh|. |
| 54 static int GetFrameId(content::RenderFrameHost* rfh); | 57 static int GetFrameId(content::RenderFrameHost* rfh); |
| 55 | 58 |
| 56 // Get the extension API frame ID for the parent of |rfh|. | 59 // Get the extension API frame ID for the parent of |rfh|. |
| 57 static int GetParentFrameId(content::RenderFrameHost* rfh); | 60 static int GetParentFrameId(content::RenderFrameHost* rfh); |
| 58 | 61 |
| 59 // Find the current RenderFrameHost for a given WebContents and extension | 62 // Find the current RenderFrameHost for a given WebContents and extension |
| 60 // frame ID. | 63 // frame ID. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // This lock protects |frame_id_map_| from being concurrently written on the | 162 // This lock protects |frame_id_map_| from being concurrently written on the |
| 160 // UI thread and read on the IO thread. | 163 // UI thread and read on the IO thread. |
| 161 base::Lock frame_id_map_lock_; | 164 base::Lock frame_id_map_lock_; |
| 162 | 165 |
| 163 DISALLOW_COPY_AND_ASSIGN(ExtensionApiFrameIdMap); | 166 DISALLOW_COPY_AND_ASSIGN(ExtensionApiFrameIdMap); |
| 164 }; | 167 }; |
| 165 | 168 |
| 166 } // namespace extensions | 169 } // namespace extensions |
| 167 | 170 |
| 168 #endif // EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_ | 171 #endif // EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_ |
| OLD | NEW |