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

Side by Side Diff: ipc/ipc_sync_channel.cc

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 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
« no previous file with comments | « ios/web/webui/web_ui_ios_controller_factory_registry.cc ('k') | jingle/glue/thread_wrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ipc/ipc_sync_channel.h" 5 #include "ipc/ipc_sync_channel.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 sync_dispatch_watcher_.reset(); 207 sync_dispatch_watcher_.reset();
208 } 208 }
209 } 209 }
210 210
211 MojoEvent* dispatch_event() { return &dispatch_event_; } 211 MojoEvent* dispatch_event() { return &dispatch_event_; }
212 base::SingleThreadTaskRunner* listener_task_runner() { 212 base::SingleThreadTaskRunner* listener_task_runner() {
213 return listener_task_runner_.get(); 213 return listener_task_runner_.get();
214 } 214 }
215 215
216 // Holds a pointer to the per-thread ReceivedSyncMsgQueue object. 216 // Holds a pointer to the per-thread ReceivedSyncMsgQueue object.
217 static base::LazyInstance<base::ThreadLocalPointer<ReceivedSyncMsgQueue> > 217 static base::LazyInstance<base::ThreadLocalPointer<ReceivedSyncMsgQueue>>::
218 lazy_tls_ptr_; 218 DestructorAtExit lazy_tls_ptr_;
219 219
220 // Called on the ipc thread to check if we can unblock any current Send() 220 // Called on the ipc thread to check if we can unblock any current Send()
221 // calls based on a queued reply. 221 // calls based on a queued reply.
222 void DispatchReplies() { 222 void DispatchReplies() {
223 for (size_t i = 0; i < received_replies_.size(); ++i) { 223 for (size_t i = 0; i < received_replies_.size(); ++i) {
224 Message* message = received_replies_[i].message; 224 Message* message = received_replies_[i].message;
225 if (received_replies_[i].context->TryToUnblockListener(message)) { 225 if (received_replies_[i].context->TryToUnblockListener(message)) {
226 delete message; 226 delete message;
227 received_replies_.erase(received_replies_.begin() + i); 227 received_replies_.erase(received_replies_.begin() + i);
228 return; 228 return;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // If not null, the address of a flag to set when the dispatch event signals, 305 // If not null, the address of a flag to set when the dispatch event signals,
306 // in lieu of actually dispatching messages. This is used by 306 // in lieu of actually dispatching messages. This is used by
307 // SyncChannel::WaitForReply to restrict the scope of queued messages we're 307 // SyncChannel::WaitForReply to restrict the scope of queued messages we're
308 // allowed to process while it's waiting. 308 // allowed to process while it's waiting.
309 bool* dispatch_flag_ = nullptr; 309 bool* dispatch_flag_ = nullptr;
310 310
311 // Watches |dispatch_event_| during all sync handle watches on this thread. 311 // Watches |dispatch_event_| during all sync handle watches on this thread.
312 std::unique_ptr<mojo::SyncHandleWatcher> sync_dispatch_watcher_; 312 std::unique_ptr<mojo::SyncHandleWatcher> sync_dispatch_watcher_;
313 }; 313 };
314 314
315 base::LazyInstance<base::ThreadLocalPointer<SyncChannel::ReceivedSyncMsgQueue> > 315 base::LazyInstance<base::ThreadLocalPointer<
316 SyncChannel::ReceivedSyncMsgQueue>>::DestructorAtExit
316 SyncChannel::ReceivedSyncMsgQueue::lazy_tls_ptr_ = 317 SyncChannel::ReceivedSyncMsgQueue::lazy_tls_ptr_ =
317 LAZY_INSTANCE_INITIALIZER; 318 LAZY_INSTANCE_INITIALIZER;
318 319
319 SyncChannel::SyncContext::SyncContext( 320 SyncChannel::SyncContext::SyncContext(
320 Listener* listener, 321 Listener* listener,
321 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, 322 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
322 WaitableEvent* shutdown_event) 323 WaitableEvent* shutdown_event)
323 : ChannelProxy::Context(listener, ipc_task_runner), 324 : ChannelProxy::Context(listener, ipc_task_runner),
324 received_sync_msgs_(ReceivedSyncMsgQueue::AddContext()), 325 received_sync_msgs_(ReceivedSyncMsgQueue::AddContext()),
325 shutdown_event_(shutdown_event), 326 shutdown_event_(shutdown_event),
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 MOJO_HANDLE_SIGNAL_READABLE, 694 MOJO_HANDLE_SIGNAL_READABLE,
694 base::Bind(&SyncChannel::OnDispatchHandleReady, 695 base::Bind(&SyncChannel::OnDispatchHandleReady,
695 base::Unretained(this))); 696 base::Unretained(this)));
696 } 697 }
697 698
698 void SyncChannel::OnChannelInit() { 699 void SyncChannel::OnChannelInit() {
699 pre_init_sync_message_filters_.clear(); 700 pre_init_sync_message_filters_.clear();
700 } 701 }
701 702
702 } // namespace IPC 703 } // namespace IPC
OLDNEW
« no previous file with comments | « ios/web/webui/web_ui_ios_controller_factory_registry.cc ('k') | jingle/glue/thread_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698