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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/web_request/web_request_api.h" 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 base::StringValue* GetStatusLine(net::HttpResponseHeaders* headers) { 338 base::StringValue* GetStatusLine(net::HttpResponseHeaders* headers) {
339 return new base::StringValue( 339 return new base::StringValue(
340 headers ? headers->GetStatusLine() : std::string()); 340 headers ? headers->GetStatusLine() : std::string());
341 } 341 }
342 342
343 void RemoveEventListenerOnUI( 343 void RemoveEventListenerOnUI(
344 void* profile_id, 344 void* profile_id,
345 const std::string& event_name, 345 const std::string& event_name,
346 int process_id, 346 int process_id,
347 const std::string& extension_id) { 347 const std::string& extension_id) {
348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 348 DCHECK_CURRENTLY_ON(BrowserThread::UI);
349 349
350 Profile* profile = reinterpret_cast<Profile*>(profile_id); 350 Profile* profile = reinterpret_cast<Profile*>(profile_id);
351 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) 351 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
352 return; 352 return;
353 353
354 extensions::EventRouter* event_router = 354 extensions::EventRouter* event_router =
355 extensions::ExtensionSystem::Get(profile)->event_router(); 355 extensions::ExtensionSystem::Get(profile)->event_router();
356 if (!event_router) 356 if (!event_router)
357 return; 357 return;
358 358
359 content::RenderProcessHost* process = 359 content::RenderProcessHost* process =
360 content::RenderProcessHost::FromID(process_id); 360 content::RenderProcessHost::FromID(process_id);
361 if (!process) 361 if (!process)
362 return; 362 return;
363 363
364 event_router->RemoveEventListener(event_name, process, extension_id); 364 event_router->RemoveEventListener(event_name, process, extension_id);
365 } 365 }
366 366
367 // Sends an event to subscribers of chrome.declarativeWebRequest.onMessage. 367 // Sends an event to subscribers of chrome.declarativeWebRequest.onMessage.
368 // |extension_id| identifies the extension that sends and receives the event. 368 // |extension_id| identifies the extension that sends and receives the event.
369 // |event_argument| is passed to the event listener. 369 // |event_argument| is passed to the event listener.
370 void SendOnMessageEventOnUI( 370 void SendOnMessageEventOnUI(
371 void* profile_id, 371 void* profile_id,
372 const std::string& extension_id, 372 const std::string& extension_id,
373 scoped_ptr<base::DictionaryValue> event_argument) { 373 scoped_ptr<base::DictionaryValue> event_argument) {
374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 374 DCHECK_CURRENTLY_ON(BrowserThread::UI);
375 375
376 Profile* profile = reinterpret_cast<Profile*>(profile_id); 376 Profile* profile = reinterpret_cast<Profile*>(profile_id);
377 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) 377 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
378 return; 378 return;
379 379
380 scoped_ptr<base::ListValue> event_args(new base::ListValue); 380 scoped_ptr<base::ListValue> event_args(new base::ListValue);
381 event_args->Append(event_argument.release()); 381 event_args->Append(event_argument.release());
382 382
383 extensions::EventRouter* event_router = 383 extensions::EventRouter* event_router =
384 extensions::ExtensionSystem::Get(profile)->event_router(); 384 extensions::ExtensionSystem::Get(profile)->event_router();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 static base::LazyInstance<BrowserContextKeyedAPIFactory<WebRequestAPI> > 426 static base::LazyInstance<BrowserContextKeyedAPIFactory<WebRequestAPI> >
427 g_factory = LAZY_INSTANCE_INITIALIZER; 427 g_factory = LAZY_INSTANCE_INITIALIZER;
428 428
429 // static 429 // static
430 BrowserContextKeyedAPIFactory<WebRequestAPI>* 430 BrowserContextKeyedAPIFactory<WebRequestAPI>*
431 WebRequestAPI::GetFactoryInstance() { 431 WebRequestAPI::GetFactoryInstance() {
432 return g_factory.Pointer(); 432 return g_factory.Pointer();
433 } 433 }
434 434
435 void WebRequestAPI::OnListenerRemoved(const EventListenerInfo& details) { 435 void WebRequestAPI::OnListenerRemoved(const EventListenerInfo& details) {
436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 436 DCHECK_CURRENTLY_ON(BrowserThread::UI);
437 // Note that details.event_name includes the sub-event details (e.g. "/123"). 437 // Note that details.event_name includes the sub-event details (e.g. "/123").
438 BrowserThread::PostTask(BrowserThread::IO, 438 BrowserThread::PostTask(BrowserThread::IO,
439 FROM_HERE, 439 FROM_HERE,
440 base::Bind(&RemoveEventListenerOnIOThread, 440 base::Bind(&RemoveEventListenerOnIOThread,
441 details.browser_context, 441 details.browser_context,
442 details.extension_id, 442 details.extension_id,
443 details.event_name)); 443 details.event_name));
444 } 444 }
445 445
446 } // namespace extensions 446 } // namespace extensions
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 2450 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
2451 adblock = true; 2451 adblock = true;
2452 } else { 2452 } else {
2453 other = true; 2453 other = true;
2454 } 2454 }
2455 } 2455 }
2456 } 2456 }
2457 2457
2458 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 2458 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
2459 } 2459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698