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

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

Issue 6598002: Make the ChromeNetworkDelegate use the ExtensionEventRouterForwarder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_io_event_router.h"
6
7 #include "googleurl/src/gurl.h"
8 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/extensions/extension_event_router.h"
10 #include "chrome/browser/profiles/profile.h"
11
12 ExtensionIOEventRouter::ExtensionIOEventRouter(Profile* profile)
13 : profile_(profile) {
14 }
15
16 ExtensionIOEventRouter::~ExtensionIOEventRouter() {
17 }
18
19 void ExtensionIOEventRouter::DispatchEventToExtension(
20 const std::string& extension_id,
21 const std::string& event_name,
22 const std::string& event_args) const {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
24 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
25 NewRunnableMethod(this,
26 &ExtensionIOEventRouter::DispatchEventOnUIThread,
27 extension_id, event_name, event_args));
28 }
29
30 void ExtensionIOEventRouter::DispatchEventToRenderers(
31 const std::string& event_name,
32 const std::string& event_args,
33 const GURL& event_url) const {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
35 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
36 NewRunnableMethod(this,
37 &ExtensionIOEventRouter::DispatchEventToRenderersOnUIThread,
38 event_name, event_args, event_url));
39 }
40
41 void ExtensionIOEventRouter::DispatchEventOnUIThread(
42 const std::string& extension_id,
43 const std::string& event_name,
44 const std::string& event_args) const {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46
47 // If the profile has gone away, we're shutting down. If there's no event
48 // router, the extension system hasn't been initialized.
49 if (!profile_ || !profile_->GetExtensionEventRouter())
50 return;
51
52 profile_->GetExtensionEventRouter()->DispatchEventToExtension(
53 extension_id, event_name, event_args, profile_, GURL());
54 }
55
56 void ExtensionIOEventRouter::DispatchEventToRenderersOnUIThread(
57 const std::string& event_name,
58 const std::string& event_args,
59 const GURL& event_url) const {
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
61
62 // If the profile has gone away, we're shutting down. If there's no event
63 // router, the extension system hasn't been initialized.
64 if (!profile_ || !profile_->GetExtensionEventRouter())
65 return;
66
67 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
68 event_name, event_args, profile_, event_url);
69 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_io_event_router.h ('k') | chrome/browser/extensions/extension_proxy_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698