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

Side by Side Diff: chrome/browser/extensions/extension_renderer_state.cc

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 #include "chrome/browser/extensions/extension_renderer_state.h" 5 #include "chrome/browser/extensions/extension_renderer_state.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/sessions/session_tab_helper.h" 10 #include "chrome/browser/sessions/session_tab_helper.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 private: 74 private:
75 // content::NotificationObserver interface. 75 // content::NotificationObserver interface.
76 virtual void Observe(int type, 76 virtual void Observe(int type,
77 const content::NotificationSource& source, 77 const content::NotificationSource& source,
78 const content::NotificationDetails& details) OVERRIDE; 78 const content::NotificationDetails& details) OVERRIDE;
79 79
80 content::NotificationRegistrar registrar_; 80 content::NotificationRegistrar registrar_;
81 }; 81 };
82 82
83 ExtensionRendererState::TabObserver::TabObserver() { 83 ExtensionRendererState::TabObserver::TabObserver() {
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 84 DCHECK_CURRENTLY_ON(BrowserThread::UI);
85 registrar_.Add(this, 85 registrar_.Add(this,
86 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 86 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
87 content::NotificationService::AllBrowserContextsAndSources()); 87 content::NotificationService::AllBrowserContextsAndSources());
88 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, 88 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED,
89 content::NotificationService::AllBrowserContextsAndSources()); 89 content::NotificationService::AllBrowserContextsAndSources());
90 registrar_.Add(this, chrome::NOTIFICATION_RETARGETING, 90 registrar_.Add(this, chrome::NOTIFICATION_RETARGETING,
91 content::NotificationService::AllBrowserContextsAndSources()); 91 content::NotificationService::AllBrowserContextsAndSources());
92 } 92 }
93 93
94 ExtensionRendererState::TabObserver::~TabObserver() { 94 ExtensionRendererState::TabObserver::~TabObserver() {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 DCHECK_CURRENTLY_ON(BrowserThread::UI);
96 } 96 }
97 97
98 void ExtensionRendererState::TabObserver::Observe( 98 void ExtensionRendererState::TabObserver::Observe(
99 int type, const content::NotificationSource& source, 99 int type, const content::NotificationSource& source,
100 const content::NotificationDetails& details) { 100 const content::NotificationDetails& details) {
101 switch (type) { 101 switch (type) {
102 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: { 102 case content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED: {
103 WebContents* web_contents = content::Source<WebContents>(source).ptr(); 103 WebContents* web_contents = content::Source<WebContents>(source).ptr();
104 SessionTabHelper* session_tab_helper = 104 SessionTabHelper* session_tab_helper =
105 SessionTabHelper::FromWebContents(web_contents); 105 SessionTabHelper::FromWebContents(web_contents);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void ExtensionRendererState::Init() { 182 void ExtensionRendererState::Init() {
183 observer_ = new TabObserver; 183 observer_ = new TabObserver;
184 } 184 }
185 185
186 void ExtensionRendererState::Shutdown() { 186 void ExtensionRendererState::Shutdown() {
187 delete observer_; 187 delete observer_;
188 } 188 }
189 189
190 void ExtensionRendererState::SetTabAndWindowId( 190 void ExtensionRendererState::SetTabAndWindowId(
191 int render_process_host_id, int routing_id, int tab_id, int window_id) { 191 int render_process_host_id, int routing_id, int tab_id, int window_id) {
192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 192 DCHECK_CURRENTLY_ON(BrowserThread::IO);
193 RenderId render_id(render_process_host_id, routing_id); 193 RenderId render_id(render_process_host_id, routing_id);
194 map_[render_id] = TabAndWindowId(tab_id, window_id); 194 map_[render_id] = TabAndWindowId(tab_id, window_id);
195 } 195 }
196 196
197 void ExtensionRendererState::ClearTabAndWindowId( 197 void ExtensionRendererState::ClearTabAndWindowId(
198 int render_process_host_id, int routing_id) { 198 int render_process_host_id, int routing_id) {
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 199 DCHECK_CURRENTLY_ON(BrowserThread::IO);
200 RenderId render_id(render_process_host_id, routing_id); 200 RenderId render_id(render_process_host_id, routing_id);
201 map_.erase(render_id); 201 map_.erase(render_id);
202 } 202 }
203 203
204 bool ExtensionRendererState::GetTabAndWindowId( 204 bool ExtensionRendererState::GetTabAndWindowId(
205 const content::ResourceRequestInfo* info, int* tab_id, int* window_id) { 205 const content::ResourceRequestInfo* info, int* tab_id, int* window_id) {
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 206 DCHECK_CURRENTLY_ON(BrowserThread::IO);
207 int render_process_id; 207 int render_process_id;
208 if (info->GetProcessType() == content::PROCESS_TYPE_PLUGIN) { 208 if (info->GetProcessType() == content::PROCESS_TYPE_PLUGIN) {
209 render_process_id = info->GetOriginPID(); 209 render_process_id = info->GetOriginPID();
210 } else { 210 } else {
211 render_process_id = info->GetChildID(); 211 render_process_id = info->GetChildID();
212 } 212 }
213 int render_view_id = info->GetRouteID(); 213 int render_view_id = info->GetRouteID();
214 RenderId render_id(render_process_id, render_view_id); 214 RenderId render_id(render_process_id, render_view_id);
215 TabAndWindowIdMap::iterator iter = map_.find(render_id); 215 TabAndWindowIdMap::iterator iter = map_.find(render_id);
216 if (iter != map_.end()) { 216 if (iter != map_.end()) {
217 *tab_id = iter->second.first; 217 *tab_id = iter->second.first;
218 *window_id = iter->second.second; 218 *window_id = iter->second.second;
219 return true; 219 return true;
220 } 220 }
221 return false; 221 return false;
222 } 222 }
223 223
224 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { 224 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) {
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 225 DCHECK_CURRENTLY_ON(BrowserThread::IO);
226 for (WebViewInfoMap::iterator i = webview_info_map_.begin(); 226 for (WebViewInfoMap::iterator i = webview_info_map_.begin();
227 i != webview_info_map_.end(); ++i) { 227 i != webview_info_map_.end(); ++i) {
228 if (i->first.first == render_process_id) 228 if (i->first.first == render_process_id)
229 return true; 229 return true;
230 } 230 }
231 return false; 231 return false;
232 } 232 }
233 233
234 void ExtensionRendererState::AddWebView(int guest_process_id, 234 void ExtensionRendererState::AddWebView(int guest_process_id,
235 int guest_routing_id, 235 int guest_routing_id,
236 const WebViewInfo& webview_info) { 236 const WebViewInfo& webview_info) {
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 237 DCHECK_CURRENTLY_ON(BrowserThread::IO);
238 RenderId render_id(guest_process_id, guest_routing_id); 238 RenderId render_id(guest_process_id, guest_routing_id);
239 webview_info_map_[render_id] = webview_info; 239 webview_info_map_[render_id] = webview_info;
240 } 240 }
241 241
242 void ExtensionRendererState::RemoveWebView(int guest_process_id, 242 void ExtensionRendererState::RemoveWebView(int guest_process_id,
243 int guest_routing_id) { 243 int guest_routing_id) {
244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 244 DCHECK_CURRENTLY_ON(BrowserThread::IO);
245 RenderId render_id(guest_process_id, guest_routing_id); 245 RenderId render_id(guest_process_id, guest_routing_id);
246 webview_info_map_.erase(render_id); 246 webview_info_map_.erase(render_id);
247 } 247 }
248 248
249 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, 249 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id,
250 int guest_routing_id, 250 int guest_routing_id,
251 WebViewInfo* webview_info) { 251 WebViewInfo* webview_info) {
252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 252 DCHECK_CURRENTLY_ON(BrowserThread::IO);
253 RenderId render_id(guest_process_id, guest_routing_id); 253 RenderId render_id(guest_process_id, guest_routing_id);
254 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); 254 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id);
255 if (iter != webview_info_map_.end()) { 255 if (iter != webview_info_map_.end()) {
256 *webview_info = iter->second; 256 *webview_info = iter->second;
257 return true; 257 return true;
258 } 258 }
259 return false; 259 return false;
260 } 260 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_messages_apitest.cc ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698