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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_endpoint_client.cc

Issue 2888053002: Rename TaskRunner::RunsTasksOnCurrentThread() in //extensions, //headless, //mojo (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/public/cpp/bindings/interface_endpoint_client.h" 5 #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 : endpoint_client_(endpoint_client), 45 : endpoint_client_(endpoint_client),
46 accept_was_invoked_(false), 46 accept_was_invoked_(false),
47 task_runner_(std::move(runner)) {} 47 task_runner_(std::move(runner)) {}
48 ~ResponderThunk() override { 48 ~ResponderThunk() override {
49 if (!accept_was_invoked_) { 49 if (!accept_was_invoked_) {
50 // The Service handled a message that was expecting a response 50 // The Service handled a message that was expecting a response
51 // but did not send a response. 51 // but did not send a response.
52 // We raise an error to signal the calling application that an error 52 // We raise an error to signal the calling application that an error
53 // condition occurred. Without this the calling application would have no 53 // condition occurred. Without this the calling application would have no
54 // way of knowing it should stop waiting for a response. 54 // way of knowing it should stop waiting for a response.
55 if (task_runner_->RunsTasksOnCurrentThread()) { 55 if (task_runner_->RunsTasksInCurrentSequence()) {
56 // Please note that even if this code is run from a different task 56 // Please note that even if this code is run from a different task
57 // runner on the same thread as |task_runner_|, it is okay to directly 57 // runner on the same thread as |task_runner_|, it is okay to directly
58 // call InterfaceEndpointClient::RaiseError(), because it will raise 58 // call InterfaceEndpointClient::RaiseError(), because it will raise
59 // error from the correct task runner asynchronously. 59 // error from the correct task runner asynchronously.
60 if (endpoint_client_) { 60 if (endpoint_client_) {
61 endpoint_client_->RaiseError(); 61 endpoint_client_->RaiseError();
62 } 62 }
63 } else { 63 } else {
64 task_runner_->PostTask( 64 task_runner_->PostTask(
65 FROM_HERE, 65 FROM_HERE,
66 base::Bind(&InterfaceEndpointClient::RaiseError, endpoint_client_)); 66 base::Bind(&InterfaceEndpointClient::RaiseError, endpoint_client_));
67 } 67 }
68 } 68 }
69 } 69 }
70 70
71 // MessageReceiver implementation: 71 // MessageReceiver implementation:
72 bool Accept(Message* message) override { 72 bool Accept(Message* message) override {
73 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 73 DCHECK(task_runner_->RunsTasksInCurrentSequence());
74 accept_was_invoked_ = true; 74 accept_was_invoked_ = true;
75 DCHECK(message->has_flag(Message::kFlagIsResponse)); 75 DCHECK(message->has_flag(Message::kFlagIsResponse));
76 76
77 bool result = false; 77 bool result = false;
78 78
79 if (endpoint_client_) 79 if (endpoint_client_)
80 result = endpoint_client_->Accept(message); 80 result = endpoint_client_->Accept(message);
81 81
82 return result; 82 return result;
83 } 83 }
84 84
85 // MessageReceiverWithStatus implementation: 85 // MessageReceiverWithStatus implementation:
86 bool IsValid() override { 86 bool IsValid() override {
87 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 87 DCHECK(task_runner_->RunsTasksInCurrentSequence());
88 return endpoint_client_ && !endpoint_client_->encountered_error(); 88 return endpoint_client_ && !endpoint_client_->encountered_error();
89 } 89 }
90 90
91 void DCheckInvalid(const std::string& message) override { 91 void DCheckInvalid(const std::string& message) override {
92 if (task_runner_->RunsTasksOnCurrentThread()) { 92 if (task_runner_->RunsTasksInCurrentSequence()) {
93 DCheckIfInvalid(endpoint_client_, message); 93 DCheckIfInvalid(endpoint_client_, message);
94 } else { 94 } else {
95 task_runner_->PostTask( 95 task_runner_->PostTask(
96 FROM_HERE, base::Bind(&DCheckIfInvalid, endpoint_client_, message)); 96 FROM_HERE, base::Bind(&DCheckIfInvalid, endpoint_client_, message));
97 } 97 }
98 } 98 }
99 99
100 private: 100 private:
101 base::WeakPtr<InterfaceEndpointClient> endpoint_client_; 101 base::WeakPtr<InterfaceEndpointClient> endpoint_client_;
102 bool accept_was_invoked_; 102 bool accept_was_invoked_;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return responder->Accept(message); 403 return responder->Accept(message);
404 } else { 404 } else {
405 if (mojo::internal::ControlMessageHandler::IsControlMessage(message)) 405 if (mojo::internal::ControlMessageHandler::IsControlMessage(message))
406 return control_message_handler_.Accept(message); 406 return control_message_handler_.Accept(message);
407 407
408 return incoming_receiver_->Accept(message); 408 return incoming_receiver_->Accept(message);
409 } 409 }
410 } 410 }
411 411
412 } // namespace mojo 412 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/node_controller.cc ('k') | mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698