Files
sdk/runtime/bin/eventhandler.h
T
jackpal@google.com e060b66a3e Add _android files for building DartVM on Android
Split directory_posix -> directory_(android|linux|macos)
  This allows us to cleanly make Android-specific changes to
  directory_android.cc

Copy all _linux files to _android files and edit as needed to account
for the differences between Linux and Android:

 + getcwd(0, NULL) doesn't work on Android, have to emulate
 + Android doesn't have a '/tmp' directory, have to emulate
 + Android doesn't provide mkdtemp(), have to emulate.
 + Small differences in the available system include files.
 + Use pthread_cond_timedwait_monotonic instead of
   pthread_condattr_setclock

Review URL: https://chromiumcodereview.appspot.com//10826233

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10613 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-13 23:06:52 +00:00

66 lines
1.7 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef BIN_EVENTHANDLER_H_
#define BIN_EVENTHANDLER_H_
#include "bin/builtin.h"
#include "bin/isolate_data.h"
// Flags used to provide information and actions to the eventhandler
// when sending a message about a file descriptor. These flags should
// be kept in sync with the constants in socket_impl.dart. For more
// information see the comments in socket_impl.dart
enum MessageFlags {
kInEvent = 0,
kOutEvent = 1,
kErrorEvent = 2,
kCloseEvent = 3,
kCloseCommand = 8,
kShutdownReadCommand = 9,
kShutdownWriteCommand = 10,
kListeningSocket = 16,
kPipe = 17,
};
// The event handler delegation class is OS specific.
#if defined(TARGET_OS_ANDROID)
#include "bin/eventhandler_android.h"
#elif defined(TARGET_OS_LINUX)
#include "bin/eventhandler_linux.h"
#elif defined(TARGET_OS_MACOS)
#include "bin/eventhandler_macos.h"
#elif defined(TARGET_OS_WINDOWS)
#include "bin/eventhandler_win.h"
#else
#error Unknown target os.
#endif
class EventHandler {
public:
void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) {
delegate_.SendData(id, dart_port, data);
}
void Shutdown() {
delegate_.Shutdown();
}
static EventHandler* Start() {
EventHandler* handler = new EventHandler();
handler->delegate_.Start();
IsolateData* isolate_data =
reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData());
isolate_data->event_handler = handler;
return handler;
}
private:
EventHandlerImplementation delegate_;
};
#endif // BIN_EVENTHANDLER_H_