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

Side by Side Diff: mojo/edk/system/core.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/edk/system/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // Note: The |reinterpret_cast| is safe, since |HandleSignalsState| is a 420 // Note: The |reinterpret_cast| is safe, since |HandleSignalsState| is a
421 // subclass of |MojoHandleSignalsState| that doesn't add any data members. 421 // subclass of |MojoHandleSignalsState| that doesn't add any data members.
422 rv = WaitManyInternal(handles, signals, num_handles, deadline, &index, 422 rv = WaitManyInternal(handles, signals, num_handles, deadline, &index,
423 reinterpret_cast<HandleSignalsState*>(signals_state)); 423 reinterpret_cast<HandleSignalsState*>(signals_state));
424 } 424 }
425 if (index != static_cast<uint32_t>(-1) && result_index) 425 if (index != static_cast<uint32_t>(-1) && result_index)
426 *result_index = index; 426 *result_index = index;
427 return rv; 427 return rv;
428 } 428 }
429 429
430 MojoResult Core::Watch(MojoHandle handle, 430 MojoResult Core::RegisterWatcher(MojoHandle handle,
431 MojoHandleSignals signals, 431 MojoHandleSignals signals,
432 MojoWatchCallback callback, 432 MojoWatchCallback callback,
433 uintptr_t context) { 433 uintptr_t context) {
434 RequestContext request_context; 434 RequestContext request_context;
435 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle); 435 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
436 if (!dispatcher) 436 if (!dispatcher)
437 return MOJO_RESULT_INVALID_ARGUMENT; 437 return MOJO_RESULT_INVALID_ARGUMENT;
438 return dispatcher->Watch( 438 return dispatcher->RegisterWatcher(
439 signals, base::Bind(&CallWatchCallback, callback, context), context); 439 signals, base::Bind(&CallWatchCallback, callback, context), context);
440 } 440 }
441 441
442 MojoResult Core::CancelWatch(MojoHandle handle, uintptr_t context) { 442 MojoResult Core::ArmWatcher(MojoHandle handle, uintptr_t context) {
443 RequestContext request_context; 443 RequestContext request_context;
444 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle); 444 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
445 if (!dispatcher) 445 if (!dispatcher)
446 return MOJO_RESULT_INVALID_ARGUMENT; 446 return MOJO_RESULT_INVALID_ARGUMENT;
447 return dispatcher->CancelWatch(context); 447 return dispatcher->ArmWatcher(context);
448 }
449
450 MojoResult Core::UnregisterWatcher(MojoHandle handle, uintptr_t context) {
451 RequestContext request_context;
452 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
453 if (!dispatcher)
454 return MOJO_RESULT_INVALID_ARGUMENT;
455 return dispatcher->UnregisterWatcher(context);
448 } 456 }
449 457
450 MojoResult Core::AllocMessage(uint32_t num_bytes, 458 MojoResult Core::AllocMessage(uint32_t num_bytes,
451 const MojoHandle* handles, 459 const MojoHandle* handles,
452 uint32_t num_handles, 460 uint32_t num_handles,
453 MojoAllocMessageFlags flags, 461 MojoAllocMessageFlags flags,
454 MojoMessageHandle* message) { 462 MojoMessageHandle* message) {
455 if (!message) 463 if (!message)
456 return MOJO_RESULT_INVALID_ARGUMENT; 464 return MOJO_RESULT_INVALID_ARGUMENT;
457 465
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 std::unique_ptr<NodeController> node_controller) { 1177 std::unique_ptr<NodeController> node_controller) {
1170 // It's OK to leak this reference. At this point we know the IO loop is still 1178 // It's OK to leak this reference. At this point we know the IO loop is still
1171 // running, and we know the NodeController will observe its eventual 1179 // running, and we know the NodeController will observe its eventual
1172 // destruction. This tells the NodeController to delete itself when that 1180 // destruction. This tells the NodeController to delete itself when that
1173 // happens. 1181 // happens.
1174 node_controller.release()->DestroyOnIOThreadShutdown(); 1182 node_controller.release()->DestroyOnIOThreadShutdown();
1175 } 1183 }
1176 1184
1177 } // namespace edk 1185 } // namespace edk
1178 } // namespace mojo 1186 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698