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

Side by Side Diff: base/message_loop/message_pump_fuchsia.cc

Issue 2941283002: fuchsia: Use new, qualified error names, disable old names. (Closed)
Patch Set: don have Created 3 years, 6 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 | « no previous file | base/process/kill_fuchsia.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "base/message_loop/message_pump_fuchsia.h" 5 #include "base/message_loop/message_pump_fuchsia.h"
6 6
7 #include <magenta/syscalls.h> 7 #include <magenta/syscalls.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 10 matching lines...) Expand all
21 __mxio_release(io_); 21 __mxio_release(io_);
22 if (was_destroyed_) { 22 if (was_destroyed_) {
23 DCHECK(!*was_destroyed_); 23 DCHECK(!*was_destroyed_);
24 *was_destroyed_ = true; 24 *was_destroyed_ = true;
25 } 25 }
26 } 26 }
27 27
28 bool MessagePumpFuchsia::FileDescriptorWatcher::StopWatchingFileDescriptor() { 28 bool MessagePumpFuchsia::FileDescriptorWatcher::StopWatchingFileDescriptor() {
29 uint64_t controller_as_key = 29 uint64_t controller_as_key =
30 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(this)); 30 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(this));
31 return mx_port_cancel(port_, handle_, controller_as_key) == NO_ERROR; 31 return mx_port_cancel(port_, handle_, controller_as_key) == MX_OK;
32 } 32 }
33 33
34 MessagePumpFuchsia::MessagePumpFuchsia() : keep_running_(true) { 34 MessagePumpFuchsia::MessagePumpFuchsia() : keep_running_(true) {
35 CHECK(mx_port_create(MX_PORT_OPT_V2, &port_) == NO_ERROR); 35 CHECK(mx_port_create(MX_PORT_OPT_V2, &port_) == MX_OK);
36 } 36 }
37 37
38 MessagePumpFuchsia::~MessagePumpFuchsia() { 38 MessagePumpFuchsia::~MessagePumpFuchsia() {
39 mx_status_t status = mx_handle_close(port_); 39 mx_status_t status = mx_handle_close(port_);
40 if (status != NO_ERROR) { 40 if (status != MX_OK) {
41 DLOG(ERROR) << "mx_handle_close failed: " << status; 41 DLOG(ERROR) << "mx_handle_close failed: " << status;
42 } 42 }
43 } 43 }
44 44
45 bool MessagePumpFuchsia::WatchFileDescriptor(int fd, 45 bool MessagePumpFuchsia::WatchFileDescriptor(int fd,
46 bool persistent, 46 bool persistent,
47 int mode, 47 int mode,
48 FileDescriptorWatcher* controller, 48 FileDescriptorWatcher* controller,
49 Watcher* delegate) { 49 Watcher* delegate) {
50 DCHECK_GE(fd, 0); 50 DCHECK_GE(fd, 0);
(...skipping 30 matching lines...) Expand all
81 __mxio_wait_begin(controller->io_, events, &controller->handle_, &signals); 81 __mxio_wait_begin(controller->io_, events, &controller->handle_, &signals);
82 if (controller->handle_ == MX_HANDLE_INVALID) 82 if (controller->handle_ == MX_HANDLE_INVALID)
83 return false; 83 return false;
84 controller->port_ = port_; 84 controller->port_ = port_;
85 85
86 uint64_t controller_as_key = 86 uint64_t controller_as_key =
87 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(controller)); 87 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(controller));
88 mx_status_t status = 88 mx_status_t status =
89 mx_object_wait_async(controller->handle_, port_, controller_as_key, 89 mx_object_wait_async(controller->handle_, port_, controller_as_key,
90 signals, MX_WAIT_ASYNC_ONCE); 90 signals, MX_WAIT_ASYNC_ONCE);
91 if (status != NO_ERROR) { 91 if (status != MX_OK) {
92 DLOG(ERROR) << "mx_object_wait_async failed: " << status; 92 DLOG(ERROR) << "mx_object_wait_async failed: " << status;
93 return false; 93 return false;
94 } 94 }
95 return true; 95 return true;
96 } 96 }
97 97
98 void MessagePumpFuchsia::Run(Delegate* delegate) { 98 void MessagePumpFuchsia::Run(Delegate* delegate) {
99 DCHECK(keep_running_); 99 DCHECK(keep_running_);
100 100
101 for (;;) { 101 for (;;) {
(...skipping 14 matching lines...) Expand all
116 116
117 if (did_work) 117 if (did_work)
118 continue; 118 continue;
119 119
120 mx_time_t deadline = delayed_work_time_.is_null() 120 mx_time_t deadline = delayed_work_time_.is_null()
121 ? MX_TIME_INFINITE 121 ? MX_TIME_INFINITE
122 : mx_time_get(MX_CLOCK_MONOTONIC) + 122 : mx_time_get(MX_CLOCK_MONOTONIC) +
123 delayed_work_time_.ToInternalValue(); 123 delayed_work_time_.ToInternalValue();
124 mx_port_packet_t packet; 124 mx_port_packet_t packet;
125 const mx_status_t wait_status = mx_port_wait(port_, deadline, &packet, 0); 125 const mx_status_t wait_status = mx_port_wait(port_, deadline, &packet, 0);
126 if (wait_status != NO_ERROR && wait_status != ERR_TIMED_OUT) { 126 if (wait_status != MX_OK && wait_status != MX_ERR_TIMED_OUT) {
127 NOTREACHED() << "unexpected wait status: " << wait_status; 127 NOTREACHED() << "unexpected wait status: " << wait_status;
128 continue; 128 continue;
129 } 129 }
130 130
131 if (packet.type == MX_PKT_TYPE_SIGNAL_ONE) { 131 if (packet.type == MX_PKT_TYPE_SIGNAL_ONE) {
132 // A watched fd caused the wakeup via mx_object_wait_async(). 132 // A watched fd caused the wakeup via mx_object_wait_async().
133 DCHECK(packet.status == NO_ERROR); 133 DCHECK(packet.status == MX_OK);
134 FileDescriptorWatcher* controller = 134 FileDescriptorWatcher* controller =
135 reinterpret_cast<FileDescriptorWatcher*>( 135 reinterpret_cast<FileDescriptorWatcher*>(
136 static_cast<uintptr_t>(packet.key)); 136 static_cast<uintptr_t>(packet.key));
137 137
138 DCHECK(packet.signal.trigger & packet.signal.observed); 138 DCHECK(packet.signal.trigger & packet.signal.observed);
139 139
140 uint32_t events; 140 uint32_t events;
141 __mxio_wait_end(controller->io_, packet.signal.observed, &events); 141 __mxio_wait_end(controller->io_, packet.signal.observed, &events);
142 // .observed can include other spurious things, in particular, that the fd 142 // .observed can include other spurious things, in particular, that the fd
143 // is writable, when we only asked to know when it was readable. In that 143 // is writable, when we only asked to know when it was readable. In that
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void MessagePumpFuchsia::Quit() { 178 void MessagePumpFuchsia::Quit() {
179 keep_running_ = false; 179 keep_running_ = false;
180 } 180 }
181 181
182 void MessagePumpFuchsia::ScheduleWork() { 182 void MessagePumpFuchsia::ScheduleWork() {
183 // Since this can be called on any thread, we need to ensure that our Run loop 183 // Since this can be called on any thread, we need to ensure that our Run loop
184 // wakes up. 184 // wakes up.
185 mx_port_packet_t packet = {}; 185 mx_port_packet_t packet = {};
186 packet.type = MX_PKT_TYPE_USER; 186 packet.type = MX_PKT_TYPE_USER;
187 mx_status_t status = mx_port_queue(port_, &packet, 0); 187 mx_status_t status = mx_port_queue(port_, &packet, 0);
188 if (status != NO_ERROR) { 188 if (status != MX_OK) {
189 DLOG(ERROR) << "mx_port_queue failed: " << status; 189 DLOG(ERROR) << "mx_port_queue failed: " << status;
190 } 190 }
191 } 191 }
192 192
193 void MessagePumpFuchsia::ScheduleDelayedWork( 193 void MessagePumpFuchsia::ScheduleDelayedWork(
194 const TimeTicks& delayed_work_time) { 194 const TimeTicks& delayed_work_time) {
195 // We know that we can't be blocked right now since this method can only be 195 // We know that we can't be blocked right now since this method can only be
196 // called on the same thread as Run, so we only need to update our record of 196 // called on the same thread as Run, so we only need to update our record of
197 // how long to sleep when we do sleep. 197 // how long to sleep when we do sleep.
198 delayed_work_time_ = delayed_work_time; 198 delayed_work_time_ = delayed_work_time;
199 } 199 }
200 200
201 } // namespace base 201 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/process/kill_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698