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

Side by Side Diff: ipc/ipc_sync_channel.cc

Issue 360042: First patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "ipc/ipc_sync_channel.h" 5 #include "ipc/ipc_sync_channel.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/thread_local.h" 9 #include "base/thread_local.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // SyncChannel objects can block the same thread). 44 // SyncChannel objects can block the same thread).
45 ReceivedSyncMsgQueue* rv = lazy_tls_ptr_.Pointer()->Get(); 45 ReceivedSyncMsgQueue* rv = lazy_tls_ptr_.Pointer()->Get();
46 if (!rv) { 46 if (!rv) {
47 rv = new ReceivedSyncMsgQueue(); 47 rv = new ReceivedSyncMsgQueue();
48 ReceivedSyncMsgQueue::lazy_tls_ptr_.Pointer()->Set(rv); 48 ReceivedSyncMsgQueue::lazy_tls_ptr_.Pointer()->Set(rv);
49 } 49 }
50 rv->listener_count_++; 50 rv->listener_count_++;
51 return rv; 51 return rv;
52 } 52 }
53 53
54 ~ReceivedSyncMsgQueue() {
55 }
56
57 // Called on IPC thread when a synchronous message or reply arrives. 54 // Called on IPC thread when a synchronous message or reply arrives.
58 void QueueMessage(const Message& msg, SyncChannel::SyncContext* context) { 55 void QueueMessage(const Message& msg, SyncChannel::SyncContext* context) {
59 bool was_task_pending; 56 bool was_task_pending;
60 { 57 {
61 AutoLock auto_lock(message_lock_); 58 AutoLock auto_lock(message_lock_);
62 59
63 was_task_pending = task_pending_; 60 was_task_pending = task_pending_;
64 task_pending_ = true; 61 task_pending_ = true;
65 62
66 // We set the event in case the listener thread is blocked (or is about 63 // We set the event in case the listener thread is blocked (or is about
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 147
151 base::WaitableEventWatcher* top_send_done_watcher() { 148 base::WaitableEventWatcher* top_send_done_watcher() {
152 return top_send_done_watcher_; 149 return top_send_done_watcher_;
153 } 150 }
154 151
155 void set_top_send_done_watcher(base::WaitableEventWatcher* watcher) { 152 void set_top_send_done_watcher(base::WaitableEventWatcher* watcher) {
156 top_send_done_watcher_ = watcher; 153 top_send_done_watcher_ = watcher;
157 } 154 }
158 155
159 private: 156 private:
157 friend class base::RefCountedThreadSafe<ReceivedSyncMsgQueue>;
158
160 // See the comment in SyncChannel::SyncChannel for why this event is created 159 // See the comment in SyncChannel::SyncChannel for why this event is created
161 // as manual reset. 160 // as manual reset.
162 ReceivedSyncMsgQueue() : 161 ReceivedSyncMsgQueue() :
163 dispatch_event_(true, false), 162 dispatch_event_(true, false),
164 listener_message_loop_(MessageLoop::current()), 163 listener_message_loop_(MessageLoop::current()),
165 task_pending_(false), 164 task_pending_(false),
166 listener_count_(0), 165 listener_count_(0),
167 top_send_done_watcher_(NULL) { 166 top_send_done_watcher_(NULL) {
168 } 167 }
169 168
169 ~ReceivedSyncMsgQueue() {}
170
170 // Holds information about a queued synchronous message or reply. 171 // Holds information about a queued synchronous message or reply.
171 struct QueuedMessage { 172 struct QueuedMessage {
172 QueuedMessage(Message* m, SyncContext* c) : message(m), context(c) { } 173 QueuedMessage(Message* m, SyncContext* c) : message(m), context(c) { }
173 Message* message; 174 Message* message;
174 scoped_refptr<SyncChannel::SyncContext> context; 175 scoped_refptr<SyncChannel::SyncContext> context;
175 }; 176 };
176 177
177 typedef std::deque<QueuedMessage> SyncMessageQueue; 178 typedef std::deque<QueuedMessage> SyncMessageQueue;
178 SyncMessageQueue message_queue_; 179 SyncMessageQueue message_queue_;
179 180
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 dispatch_watcher_.StartWatching(dispatch_event, this); 483 dispatch_watcher_.StartWatching(dispatch_event, this);
483 sync_context()->DispatchMessages(); 484 sync_context()->DispatchMessages();
484 } else { 485 } else {
485 // We got the reply, timed out or the process shutdown. 486 // We got the reply, timed out or the process shutdown.
486 DCHECK(event == sync_context()->GetSendDoneEvent()); 487 DCHECK(event == sync_context()->GetSendDoneEvent());
487 MessageLoop::current()->Quit(); 488 MessageLoop::current()->Quit();
488 } 489 }
489 } 490 }
490 491
491 } // namespace IPC 492 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698