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

Side by Side Diff: chrome/browser/notifications/notification_object_proxy.cc

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/notifications/notification_object_proxy.h" 5 #include "chrome/browser/notifications/notification_object_proxy.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon. 44 // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
45 NOTREACHED(); 45 NOTREACHED();
46 } else { 46 } else {
47 DeliverMessage(new ViewMsg_PostCloseToNotificationObject( 47 DeliverMessage(new ViewMsg_PostCloseToNotificationObject(
48 route_id_, notification_id_, by_user)); 48 route_id_, notification_id_, by_user));
49 } 49 }
50 } 50 }
51 51
52 void NotificationObjectProxy::DeliverMessage(IPC::Message* message) { 52 void NotificationObjectProxy::DeliverMessage(IPC::Message* message) {
53 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 53 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
54 MessageLoop* io_loop = ChromeThread::GetMessageLoop(ChromeThread::IO); 54 ChromeThread::PostTask(
55 if (io_loop) { 55 ChromeThread::IO, FROM_HERE,
56 io_loop->PostTask(FROM_HERE, 56 NewRunnableMethod(this, &NotificationObjectProxy::Send, message));
57 NewRunnableMethod(this, &NotificationObjectProxy::Send, message));
58 }
59 } 57 }
60 58
61 // Deferred method which runs on the IO thread and sends a message to the 59 // Deferred method which runs on the IO thread and sends a message to the
62 // proxied notification, routing it through the correct host in the browser. 60 // proxied notification, routing it through the correct host in the browser.
63 void NotificationObjectProxy::Send(IPC::Message* message) { 61 void NotificationObjectProxy::Send(IPC::Message* message) {
64 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 62 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
65 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_); 63 RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
66 if (host) 64 if (host)
67 host->Send(message); 65 host->Send(message);
68 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698