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

Side by Side Diff: ipc/ipc_channel_win.cc

Issue 2375663002: Replace MessageLoop::current()->task_runner() with ThreadTaskRunnerHandle::Get(). (Closed)
Patch Set: rebase Created 4 years, 2 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 | « ipc/ipc_channel_reader.cc ('k') | services/shell/standalone/context.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_channel_win.h" 5 #include "ipc/ipc_channel_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/pickle.h" 16 #include "base/pickle.h"
17 #include "base/process/process_handle.h" 17 #include "base/process/process_handle.h"
18 #include "base/rand_util.h" 18 #include "base/rand_util.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
23 #include "base/threading/thread_task_runner_handle.h"
23 #include "base/win/scoped_handle.h" 24 #include "base/win/scoped_handle.h"
24 #include "ipc/attachment_broker.h" 25 #include "ipc/attachment_broker.h"
25 #include "ipc/ipc_listener.h" 26 #include "ipc/ipc_listener.h"
26 #include "ipc/ipc_logging.h" 27 #include "ipc/ipc_logging.h"
27 #include "ipc/ipc_message_attachment_set.h" 28 #include "ipc/ipc_message_attachment_set.h"
28 #include "ipc/ipc_message_utils.h" 29 #include "ipc/ipc_message_utils.h"
29 30
30 namespace IPC { 31 namespace IPC {
31 32
32 ChannelWin::State::State() = default; 33 ChannelWin::State::State() = default;
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 pipe_.Close(); 387 pipe_.Close();
387 return false; 388 return false;
388 } 389 }
389 390
390 OutputElement* element = new OutputElement(m.release()); 391 OutputElement* element = new OutputElement(m.release());
391 output_queue_.push(element); 392 output_queue_.push(element);
392 return true; 393 return true;
393 } 394 }
394 395
395 bool ChannelWin::Connect() { 396 bool ChannelWin::Connect() {
397 DCHECK(base::MessageLoopForIO::IsCurrent());
398
396 WillConnect(); 399 WillConnect();
397 400
398 DLOG_IF(WARNING, thread_check_.get()) << "Connect called more than once"; 401 DLOG_IF(WARNING, thread_check_.get()) << "Connect called more than once";
399 402
400 if (!thread_check_.get()) 403 if (!thread_check_.get())
401 thread_check_.reset(new base::ThreadChecker()); 404 thread_check_.reset(new base::ThreadChecker());
402 405
403 if (!pipe_.IsValid()) 406 if (!pipe_.IsValid())
404 return false; 407 return false;
405 408
406 base::MessageLoopForIO::current()->RegisterIOHandler(pipe_.Get(), this); 409 base::MessageLoopForIO::current()->RegisterIOHandler(pipe_.Get(), this);
407 410
408 // Check to see if there is a client connected to our pipe... 411 // Check to see if there is a client connected to our pipe...
409 if (waiting_connect_) 412 if (waiting_connect_)
410 ProcessConnection(); 413 ProcessConnection();
411 414
412 if (!input_state_.is_pending) { 415 if (!input_state_.is_pending) {
413 // Complete setup asynchronously. By not setting input_state_.is_pending 416 // Complete setup asynchronously. By not setting input_state_.is_pending
414 // to true, we indicate to OnIOCompleted that this is the special 417 // to true, we indicate to OnIOCompleted that this is the special
415 // initialization signal. 418 // initialization signal.
416 base::MessageLoopForIO::current()->task_runner()->PostTask( 419 base::ThreadTaskRunnerHandle::Get()->PostTask(
417 FROM_HERE, 420 FROM_HERE,
418 base::Bind(&ChannelWin::OnIOCompleted, weak_factory_.GetWeakPtr(), 421 base::Bind(&ChannelWin::OnIOCompleted, weak_factory_.GetWeakPtr(),
419 &input_state_.context, 0, 0)); 422 &input_state_.context, 0, 0));
420 } 423 }
421 424
422 if (!waiting_connect_) 425 if (!waiting_connect_)
423 ProcessOutgoingMessages(NULL, 0); 426 ProcessOutgoingMessages(NULL, 0);
424 return true; 427 return true;
425 } 428 }
426 429
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 int secret; 607 int secret;
605 do { // Guarantee we get a non-zero value. 608 do { // Guarantee we get a non-zero value.
606 secret = base::RandInt(0, std::numeric_limits<int>::max()); 609 secret = base::RandInt(0, std::numeric_limits<int>::max());
607 } while (secret == 0); 610 } while (secret == 0);
608 611
609 id.append(GenerateUniqueRandomChannelID()); 612 id.append(GenerateUniqueRandomChannelID());
610 return id.append(base::StringPrintf("\\%d", secret)); 613 return id.append(base::StringPrintf("\\%d", secret));
611 } 614 }
612 615
613 } // namespace IPC 616 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_reader.cc ('k') | services/shell/standalone/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698