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

Side by Side Diff: extensions/browser/extension_api_frame_id_map.h

Issue 1670673003: Refactor the implementation of the webNavigation extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Bug-532666-NavigationHandleAPI
Patch Set: Remove UI thread DCHECKs. Created 4 years, 10 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 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
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 15
16 namespace content { 16 namespace content {
17 class NavigationHandle;
17 class RenderFrameHost; 18 class RenderFrameHost;
18 class WebContents; 19 class WebContents;
19 } // namespace content 20 } // namespace content
20 21
21 namespace extensions { 22 namespace extensions {
22 23
23 // Extension frame IDs are exposed through the chrome.* APIs and have the 24 // Extension frame IDs are exposed through the chrome.* APIs and have the
24 // following characteristics: 25 // following characteristics:
25 // - The top-level frame has ID 0. 26 // - The top-level frame has ID 0.
26 // - Any child frame has a positive ID. 27 // - Any child frame has a positive ID.
(...skipping 19 matching lines...) Expand all
46 int extension_api_parent_frame_id)>; 47 int extension_api_parent_frame_id)>;
47 48
48 // An invalid extension API frame ID. 49 // An invalid extension API frame ID.
49 static const int kInvalidFrameId; 50 static const int kInvalidFrameId;
50 51
51 static ExtensionApiFrameIdMap* Get(); 52 static ExtensionApiFrameIdMap* Get();
52 53
53 // Get the extension API frame ID for |rfh|. 54 // Get the extension API frame ID for |rfh|.
54 static int GetFrameId(content::RenderFrameHost* rfh); 55 static int GetFrameId(content::RenderFrameHost* rfh);
55 56
57 // Get the extension API frame ID for |navigation_handle|.
58 static int GetFrameId(content::NavigationHandle* navigation_handle);
59
56 // Get the extension API frame ID for the parent of |rfh|. 60 // Get the extension API frame ID for the parent of |rfh|.
57 static int GetParentFrameId(content::RenderFrameHost* rfh); 61 static int GetParentFrameId(content::RenderFrameHost* rfh);
58 62
63 // Get the extension API frame ID for the parent of |navigation_handle|.
64 static int GetParentFrameId(content::NavigationHandle* navigation_handle);
65
59 // Find the current RenderFrameHost for a given WebContents and extension 66 // Find the current RenderFrameHost for a given WebContents and extension
60 // frame ID. 67 // frame ID.
61 // Returns nullptr if not found. 68 // Returns nullptr if not found.
62 static content::RenderFrameHost* GetRenderFrameHostById( 69 static content::RenderFrameHost* GetRenderFrameHostById(
63 content::WebContents* web_contents, 70 content::WebContents* web_contents,
64 int frame_id); 71 int frame_id);
65 72
66 // Runs |callback| with the result that is equivalent to calling GetFrameId() 73 // Runs |callback| with the result that is equivalent to calling GetFrameId()
67 // on the UI thread. Thread hopping is minimized if possible. Callbacks for 74 // on the UI thread. Thread hopping is minimized if possible. Callbacks for
68 // the same |render_process_id| and |frame_routing_id| are guaranteed to be 75 // the same |render_process_id| and |frame_routing_id| are guaranteed to be
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // This lock protects |frame_id_map_| from being concurrently written on the 166 // This lock protects |frame_id_map_| from being concurrently written on the
160 // UI thread and read on the IO thread. 167 // UI thread and read on the IO thread.
161 base::Lock frame_id_map_lock_; 168 base::Lock frame_id_map_lock_;
162 169
163 DISALLOW_COPY_AND_ASSIGN(ExtensionApiFrameIdMap); 170 DISALLOW_COPY_AND_ASSIGN(ExtensionApiFrameIdMap);
164 }; 171 };
165 172
166 } // namespace extensions 173 } // namespace extensions
167 174
168 #endif // EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_ 175 #endif // EXTENSIONS_BROWSER_EXTENSION_API_FRAME_ID_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698