| Index: third_party/WebKit/Source/core/mojo/Mojo.h
|
| diff --git a/third_party/WebKit/Source/core/mojo/Mojo.h b/third_party/WebKit/Source/core/mojo/Mojo.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c0a1fd0af4288040db966d6e1f58e034aaf3a586
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/mojo/Mojo.h
|
| @@ -0,0 +1,116 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef Mojo_h
|
| +#define Mojo_h
|
| +
|
| +#include "bindings/core/v8/ScriptWrappable.h"
|
| +#include "core/mojo/MojoHandleWatcher.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class DOMArrayBuffer;
|
| +class MojoCreateMessagePipeOptions;
|
| +class MojoCreateMessagePipeResult;
|
| +class MojoHandle;
|
| +class MojoMessagePipeHandle;
|
| +class MojoReadMessageResult;
|
| +class MojoWatchCallback;
|
| +class ScriptState;
|
| +
|
| +class Mojo final : public GarbageCollectedFinalized<Mojo>,
|
| + public ScriptWrappable {
|
| + DEFINE_WRAPPERTYPEINFO();
|
| +
|
| + public:
|
| + CORE_EXPORT static Mojo* create();
|
| + virtual ~Mojo();
|
| +
|
| + // MojoResult
|
| + static const MojoResult kResultOk = MOJO_HANDLE_SIGNAL_NONE;
|
| + static const MojoResult kResultCancelled = MOJO_RESULT_CANCELLED;
|
| + static const MojoResult kResultUnknown = MOJO_RESULT_UNKNOWN;
|
| + static const MojoResult kResultInvalidArgument = MOJO_RESULT_INVALID_ARGUMENT;
|
| + static const MojoResult kResultDeadlineExceeded =
|
| + MOJO_RESULT_DEADLINE_EXCEEDED;
|
| + static const MojoResult kResultNotFound = MOJO_RESULT_NOT_FOUND;
|
| + static const MojoResult kResultAlreadyExists = MOJO_RESULT_ALREADY_EXISTS;
|
| + static const MojoResult kResultPermissionDenied =
|
| + MOJO_RESULT_PERMISSION_DENIED;
|
| + static const MojoResult kResultResourceExhausted =
|
| + MOJO_RESULT_RESOURCE_EXHAUSTED;
|
| + static const MojoResult kResultFailedPrecondition =
|
| + MOJO_RESULT_FAILED_PRECONDITION;
|
| + static const MojoResult kResultAborted = MOJO_RESULT_ABORTED;
|
| + static const MojoResult kResultOutOfRange = MOJO_RESULT_OUT_OF_RANGE;
|
| + static const MojoResult kResultUnimplemented = MOJO_RESULT_UNIMPLEMENTED;
|
| + static const MojoResult kResultInternal = MOJO_RESULT_INTERNAL;
|
| + static const MojoResult kResultUnavailable = MOJO_RESULT_UNAVAILABLE;
|
| + static const MojoResult kResultDataLoss = MOJO_RESULT_DATA_LOSS;
|
| + static const MojoResult kResultBusy = MOJO_RESULT_BUSY;
|
| + static const MojoResult kResultShouldWait = MOJO_RESULT_SHOULD_WAIT;
|
| +
|
| + // MojoHandleSignals
|
| + static const MojoHandleSignals kHandleSignalNone = MOJO_HANDLE_SIGNAL_NONE;
|
| + static const MojoHandleSignals kHandleSignalReadable =
|
| + MOJO_HANDLE_SIGNAL_READABLE;
|
| + static const MojoHandleSignals kHandleSignalWritable =
|
| + MOJO_HANDLE_SIGNAL_WRITABLE;
|
| + static const MojoHandleSignals kHandleSignalPeerClosed =
|
| + MOJO_HANDLE_SIGNAL_PEER_CLOSED;
|
| +
|
| + // MessagePipe flags.
|
| + static const MojoCreateMessagePipeOptionsFlags
|
| + kCreateMessagePipeOptionsFlagNone =
|
| + MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE;
|
| + static const MojoWriteMessageFlags kWriteMessageFlagNone =
|
| + MOJO_WRITE_MESSAGE_FLAG_NONE;
|
| + static const MojoReadMessageFlags kReadMessageFlagNone =
|
| + MOJO_READ_MESSAGE_FLAG_NONE;
|
| + static const MojoReadMessageFlags kReadMessageFlagMayDiscard =
|
| + MOJO_READ_MESSAGE_FLAG_MAY_DISCARD;
|
| +
|
| + unsigned watch(ScriptState*,
|
| + MojoHandle*,
|
| + MojoHandleSignals,
|
| + MojoWatchCallback*);
|
| + void cancelWatch(unsigned watchId);
|
| +
|
| + void createMessagePipe(const MojoCreateMessagePipeOptions&,
|
| + MojoCreateMessagePipeResult&);
|
| + MojoResult writeMessage(MojoMessagePipeHandle*,
|
| + DOMArrayBuffer*,
|
| + const HeapVector<Member<MojoHandle>>&,
|
| + MojoWriteMessageFlags);
|
| + void readMessage(MojoMessagePipeHandle*,
|
| + MojoReadMessageFlags,
|
| + MojoReadMessageResult&);
|
| +
|
| + DECLARE_TRACE();
|
| +
|
| + private:
|
| + class WatchEntry : public GarbageCollectedFinalized<WatchEntry> {
|
| + public:
|
| + WatchEntry(WebTaskRunner* taskRunner) : m_watcher(taskRunner) {}
|
| + DECLARE_TRACE();
|
| +
|
| + private:
|
| + friend class Mojo;
|
| + MojoHandleWatcher m_watcher;
|
| + RefPtr<ScriptState> m_scriptState;
|
| + Member<MojoWatchCallback> m_callback;
|
| + };
|
| + using WatchMap = HeapHashMap<unsigned, Member<WatchEntry>>;
|
| +
|
| + Mojo(std::unique_ptr<WebTaskRunner>);
|
| + void watchCallback(unsigned, MojoResult);
|
| +
|
| + std::unique_ptr<WebTaskRunner> m_taskRunner;
|
| + unsigned m_nextWatchId;
|
| + WatchMap m_watchMap;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // Mojo_h
|
|
|