summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Blundell <blundell@chromium.org>2015-01-19 13:17:50 +0100
committerColin Blundell <blundell@chromium.org>2015-01-19 12:20:14 +0000
commit835d018d323f35bd8d9b0d645caf180705b0a7da (patch)
treefc84cfdcb2bba73f3edb5bfeb9fff7797a46e02e
parent71f9904e069bac7cd87140ad9006890392b04ea2 (diff)
downloadchromium_src-835d018d323f35bd8d9b0d645caf180705b0a7da.zip
chromium_src-835d018d323f35bd8d9b0d645caf180705b0a7da.tar.gz
chromium_src-835d018d323f35bd8d9b0d645caf180705b0a7da.tar.bz2
Update mojo sdk to rev b737c0531e299ad494725c518699843e76ff84f5
Incorporates changes from https://codereview.chromium.org/849133003/ to adapt to API changes in surfaces and ConnectToApplication. TBR=ben@chromium.org, jamesr@chromium.org Review URL: https://codereview.chromium.org/858603002 Cr-Commit-Position: refs/heads/master@{#312096}
-rw-r--r--DEPS5
-rw-r--r--mojo/cc/output_surface_mojo.cc19
-rw-r--r--mojo/cc/output_surface_mojo.h5
-rw-r--r--mojo/edk/embedder/embedder.cc15
-rw-r--r--mojo/edk/system/channel.cc10
-rw-r--r--mojo/edk/system/channel.h5
-rw-r--r--mojo/edk/system/channel_unittest.cc89
-rw-r--r--mojo/edk/system/message_pipe_test_utils.cc2
-rw-r--r--mojo/edk/system/raw_channel.cc16
-rw-r--r--mojo/edk/system/raw_channel.h7
-rw-r--r--mojo/edk/system/raw_channel_posix.cc22
-rw-r--r--mojo/edk/system/raw_channel_unittest.cc2
-rw-r--r--mojo/edk/system/raw_channel_win.cc15
-rw-r--r--mojo/edk/system/remote_message_pipe_unittest.cc4
-rw-r--r--mojo/mojo_services_public.gyp38
-rw-r--r--mojo/public/VERSION2
-rw-r--r--mojo/public/cpp/application/application_impl.h3
-rw-r--r--mojo/public/cpp/application/lib/application_impl.cc18
-rw-r--r--mojo/public/cpp/application/lib/service_registry.cc15
-rw-r--r--mojo/public/cpp/application/lib/service_registry.h4
-rw-r--r--mojo/public/cpp/bindings/array.h8
-rw-r--r--mojo/public/cpp/bindings/binding.h13
-rw-r--r--mojo/public/cpp/bindings/interface_ptr.h16
-rw-r--r--mojo/public/cpp/bindings/interface_request.h8
-rw-r--r--mojo/public/cpp/bindings/lib/filter_chain.cc12
-rw-r--r--mojo/public/cpp/bindings/lib/filter_chain.h8
-rw-r--r--mojo/public/cpp/bindings/map.h9
-rw-r--r--mojo/public/cpp/bindings/strong_binding.h8
-rw-r--r--mojo/public/cpp/bindings/struct_ptr.h30
-rw-r--r--mojo/public/cpp/bindings/tests/container_test_util.cc8
-rw-r--r--mojo/public/cpp/bindings/tests/container_test_util.h6
-rw-r--r--mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc8
-rw-r--r--mojo/public/cpp/bindings/tests/struct_unittest.cc24
-rw-r--r--mojo/public/cpp/system/handle.h10
-rw-r--r--mojo/public/cpp/system/macros.h28
-rw-r--r--mojo/public/cpp/system/tests/macros_unittest.cc14
-rw-r--r--mojo/public/dart/core.dart1
-rw-r--r--mojo/public/dart/src/buffer.dart35
-rw-r--r--mojo/public/dart/src/client.dart130
-rw-r--r--mojo/public/dart/src/codec.dart193
-rw-r--r--mojo/public/dart/src/data_pipe.dart67
-rw-r--r--mojo/public/dart/src/event_stream.dart207
-rw-r--r--mojo/public/dart/src/handle.dart115
-rw-r--r--mojo/public/dart/src/interface.dart131
-rw-r--r--mojo/public/interfaces/application/application.mojom10
-rw-r--r--mojo/public/interfaces/application/service_provider.mojom2
-rw-r--r--mojo/public/interfaces/application/shell.mojom8
-rw-r--r--mojo/public/js/codec.js2
-rw-r--r--mojo/public/js/connector.js3
-rw-r--r--mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl55
-rw-r--r--mojo/public/tools/bindings/generators/mojom_dart_generator.py80
-rw-r--r--mojo/public/tools/bindings/mojom.gni12
-rwxr-xr-xmojo/public/tools/download_shell_binary.py35
-rw-r--r--mojo/services/accessibility/public/interfaces/BUILD.gn2
-rw-r--r--mojo/services/accessibility/public/interfaces/accessibility.mojom2
-rw-r--r--mojo/services/content_handler/public/interfaces/BUILD.gn2
-rw-r--r--mojo/services/content_handler/public/interfaces/content_handler.mojom2
-rw-r--r--mojo/services/gpu/public/interfaces/BUILD.gn4
-rw-r--r--mojo/services/gpu/public/interfaces/command_buffer.mojom2
-rw-r--r--mojo/services/gpu/public/interfaces/gpu.mojom6
-rw-r--r--mojo/services/html_viewer/html_document.cc8
-rw-r--r--mojo/services/html_viewer/html_document.h6
-rw-r--r--mojo/services/html_viewer/html_viewer.cc15
-rw-r--r--mojo/services/html_viewer/webmediaplayer_factory.cc4
-rw-r--r--mojo/services/input_events/public/interfaces/BUILD.gn4
-rw-r--r--mojo/services/input_events/public/interfaces/input_events.mojom6
-rw-r--r--mojo/services/native_viewport/public/interfaces/BUILD.gn10
-rw-r--r--mojo/services/native_viewport/public/interfaces/native_viewport.mojom8
-rw-r--r--mojo/services/navigation/public/interfaces/BUILD.gn4
-rw-r--r--mojo/services/navigation/public/interfaces/navigation.mojom2
-rw-r--r--mojo/services/network/public/interfaces/BUILD.gn2
-rw-r--r--mojo/services/network/public/interfaces/network_service.mojom16
-rw-r--r--mojo/services/network/public/interfaces/tcp_bound_socket.mojom8
-rw-r--r--mojo/services/network/public/interfaces/tcp_server_socket.mojom6
-rw-r--r--mojo/services/network/public/interfaces/udp_socket.mojom4
-rw-r--r--mojo/services/network/public/interfaces/url_loader.mojom2
-rw-r--r--mojo/services/network/public/interfaces/web_socket.mojom2
-rw-r--r--mojo/services/public/js/application.js14
-rw-r--r--mojo/services/surfaces/public/interfaces/BUILD.gn8
-rw-r--r--mojo/services/surfaces/public/interfaces/quads.mojom4
-rw-r--r--mojo/services/surfaces/public/interfaces/surface_id.mojom6
-rw-r--r--mojo/services/surfaces/public/interfaces/surfaces.mojom20
-rw-r--r--mojo/services/surfaces/public/interfaces/surfaces_service.mojom4
-rw-r--r--mojo/services/view_manager/public/cpp/tests/BUILD.gn8
-rw-r--r--mojo/services/view_manager/public/cpp/tests/DEPS2
-rw-r--r--mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc2
-rw-r--r--mojo/services/view_manager/public/interfaces/BUILD.gn2
-rw-r--r--mojo/services/view_manager/public/interfaces/animations.mojom2
-rw-r--r--mojo/services/view_manager/public/interfaces/view_manager.mojom10
-rw-r--r--mojo/services/window_manager/public/interfaces/BUILD.gn6
-rw-r--r--mojo/services/window_manager/public/interfaces/window_manager.mojom2
-rw-r--r--mojo/services/window_manager/public/interfaces/window_manager_internal.mojom4
92 files changed, 1046 insertions, 767 deletions
diff --git a/DEPS b/DEPS
index 223e4ab..c4bef85 100644
--- a/DEPS
+++ b/DEPS
@@ -737,7 +737,10 @@ hooks = [
{
'name': 'download_mojo_shell',
'pattern': '',
- 'action': [ 'python', 'src/mojo/public/tools/download_shell_binary.py' ],
+ 'action': [ 'python',
+ 'src/mojo/public/tools/download_shell_binary.py',
+ '--tools-directory=../../../tools',
+ ],
},
{
# A change to a .gyp, .gypi, or to GYP itself should run the generator.
diff --git a/mojo/cc/output_surface_mojo.cc b/mojo/cc/output_surface_mojo.cc
index 9978992..8a979e4 100644
--- a/mojo/cc/output_surface_mojo.cc
+++ b/mojo/cc/output_surface_mojo.cc
@@ -19,7 +19,8 @@ OutputSurfaceMojo::OutputSurfaceMojo(
: cc::OutputSurface(context_provider),
output_surface_mojo_client_(client),
surface_(surface.Pass()),
- id_allocator_(id_namespace) {
+ id_namespace_(id_namespace),
+ local_id_(0u) {
capabilities_.delegated_rendering = true;
capabilities_.max_frames_pending = 1;
}
@@ -28,6 +29,7 @@ OutputSurfaceMojo::~OutputSurfaceMojo() {
}
void OutputSurfaceMojo::SetIdNamespace(uint32_t id_namespace) {
+ id_namespace_ = id_namespace;
}
void OutputSurfaceMojo::ReturnResources(Array<ReturnedResourcePtr> resources) {
@@ -42,17 +44,18 @@ void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) {
gfx::Size frame_size =
frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
if (frame_size != surface_size_) {
- if (!surface_id_.is_null()) {
- surface_->DestroySurface(SurfaceId::From(surface_id_));
+ if (local_id_ != 0u) {
+ surface_->DestroySurface(local_id_);
}
- surface_id_ = id_allocator_.GenerateId();
- surface_->CreateSurface(SurfaceId::From(surface_id_));
- output_surface_mojo_client_->DidCreateSurface(surface_id_);
+ local_id_++;
+ surface_->CreateSurface(local_id_);
+ cc::SurfaceId qualified_id(static_cast<uint64_t>(id_namespace_) << 32 |
+ local_id_);
+ output_surface_mojo_client_->DidCreateSurface(qualified_id);
surface_size_ = frame_size;
}
- surface_->SubmitFrame(SurfaceId::From(surface_id_), Frame::From(*frame),
- mojo::Closure());
+ surface_->SubmitFrame(local_id_, Frame::From(*frame), mojo::Closure());
client_->DidSwapBuffers();
client_->DidSwapBuffersComplete();
diff --git a/mojo/cc/output_surface_mojo.h b/mojo/cc/output_surface_mojo.h
index 3aa14d1..6a2682d 100644
--- a/mojo/cc/output_surface_mojo.h
+++ b/mojo/cc/output_surface_mojo.h
@@ -8,7 +8,6 @@
#include "base/macros.h"
#include "cc/output/output_surface.h"
#include "cc/surfaces/surface_id.h"
-#include "cc/surfaces/surface_id_allocator.h"
#include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
namespace mojo {
@@ -41,8 +40,8 @@ class OutputSurfaceMojo : public cc::OutputSurface, public SurfaceClient {
OutputSurfaceMojoClient* output_surface_mojo_client_;
SurfacePtr surface_;
- cc::SurfaceIdAllocator id_allocator_;
- cc::SurfaceId surface_id_;
+ uint32_t id_namespace_;
+ uint32_t local_id_;
gfx::Size surface_size_;
DISALLOW_COPY_AND_ASSIGN(OutputSurfaceMojo);
diff --git a/mojo/edk/embedder/embedder.cc b/mojo/edk/embedder/embedder.cc
index 622b3b7..1d12c1e 100644
--- a/mojo/edk/embedder/embedder.cc
+++ b/mojo/edk/embedder/embedder.cc
@@ -36,14 +36,7 @@ system::ChannelId MakeChannel(
DCHECK(internal::g_core);
scoped_refptr<system::Channel> channel =
new system::Channel(internal::g_core->platform_support());
- if (!channel->Init(system::RawChannel::Create(platform_handle.Pass()))) {
- // This is very unusual (e.g., maybe |platform_handle| was invalid or we
- // reached some system resource limit).
- LOG(ERROR) << "Channel::Init() failed";
- // Return null, since |Shutdown()| shouldn't be called in this case.
- return 0;
- }
-
+ channel->Init(system::RawChannel::Create(platform_handle.Pass()));
channel->SetBootstrapEndpoint(channel_endpoint);
DCHECK(internal::g_channel_manager);
@@ -150,11 +143,7 @@ ScopedMessagePipeHandle CreateChannel(
// TODO(vtl): Write tests for this.
void DestroyChannel(ChannelInfo* channel_info) {
DCHECK(channel_info);
- if (!channel_info->channel_id) {
- // Presumably, |Init()| on the channel failed.
- return;
- }
-
+ DCHECK(channel_info->channel_id);
DCHECK(internal::g_channel_manager);
// This will destroy the channel synchronously if called from the channel
// thread.
diff --git a/mojo/edk/system/channel.cc b/mojo/edk/system/channel.cc
index 8889919..71d7208 100644
--- a/mojo/edk/system/channel.cc
+++ b/mojo/edk/system/channel.cc
@@ -36,7 +36,7 @@ Channel::Channel(embedder::PlatformSupport* platform_support)
channel_manager_(nullptr) {
}
-bool Channel::Init(scoped_ptr<RawChannel> raw_channel) {
+void Channel::Init(scoped_ptr<RawChannel> raw_channel) {
DCHECK(creation_thread_checker_.CalledOnValidThread());
DCHECK(raw_channel);
@@ -44,14 +44,8 @@ bool Channel::Init(scoped_ptr<RawChannel> raw_channel) {
// becomes thread-safe.
DCHECK(!is_running_);
raw_channel_ = raw_channel.Pass();
-
- if (!raw_channel_->Init(this)) {
- raw_channel_.reset();
- return false;
- }
-
+ raw_channel_->Init(this);
is_running_ = true;
- return true;
}
void Channel::SetChannelManager(ChannelManager* channel_manager) {
diff --git a/mojo/edk/system/channel.h b/mojo/edk/system/channel.h
index 64acb7d..3961859 100644
--- a/mojo/edk/system/channel.h
+++ b/mojo/edk/system/channel.h
@@ -60,9 +60,8 @@ class MOJO_SYSTEM_IMPL_EXPORT Channel
// This must be called on the creation thread before any other methods are
// called, and before references to this object are given to any other
- // threads. |raw_channel| should be uninitialized. Returns true on success. On
- // failure, no other methods should be called (including |Shutdown()|).
- bool Init(scoped_ptr<RawChannel> raw_channel);
+ // threads. |raw_channel| should be uninitialized.
+ void Init(scoped_ptr<RawChannel> raw_channel);
// Sets the channel manager associated with this channel. This should be set
// at most once and only called before |WillShutdownSoon()| (and
diff --git a/mojo/edk/system/channel_unittest.cc b/mojo/edk/system/channel_unittest.cc
index 741c99f..e82b321 100644
--- a/mojo/edk/system/channel_unittest.cc
+++ b/mojo/edk/system/channel_unittest.cc
@@ -22,17 +22,9 @@ namespace mojo {
namespace system {
namespace {
-enum Tristate { TRISTATE_UNKNOWN = -1, TRISTATE_FALSE = 0, TRISTATE_TRUE = 1 };
-
-Tristate BoolToTristate(bool b) {
- return b ? TRISTATE_TRUE : TRISTATE_FALSE;
-}
-
class ChannelTest : public testing::Test {
public:
- ChannelTest()
- : io_thread_(base::TestIOThread::kAutoStart),
- init_result_(TRISTATE_UNKNOWN) {}
+ ChannelTest() : io_thread_(base::TestIOThread::kAutoStart) {}
~ChannelTest() override {}
void SetUp() override {
@@ -51,9 +43,7 @@ class ChannelTest : public testing::Test {
CHECK(raw_channel_);
CHECK(channel_);
- CHECK_EQ(init_result_, TRISTATE_UNKNOWN);
-
- init_result_ = BoolToTristate(channel_->Init(raw_channel_.Pass()));
+ channel_->Init(raw_channel_.Pass());
}
void ShutdownChannelOnIOThread() {
@@ -68,7 +58,6 @@ class ChannelTest : public testing::Test {
scoped_ptr<RawChannel>* mutable_raw_channel() { return &raw_channel_; }
Channel* channel() { return channel_.get(); }
scoped_refptr<Channel>* mutable_channel() { return &channel_; }
- Tristate init_result() const { return init_result_; }
private:
void SetUpOnIOThread() {
@@ -85,8 +74,6 @@ class ChannelTest : public testing::Test {
embedder::ScopedPlatformHandle other_platform_handle_;
scoped_refptr<Channel> channel_;
- Tristate init_result_;
-
DISALLOW_COPY_AND_ASSIGN(ChannelTest);
};
@@ -101,7 +88,6 @@ TEST_F(ChannelTest, InitShutdown) {
io_thread()->PostTaskAndWait(
FROM_HERE,
base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
- EXPECT_EQ(TRISTATE_TRUE, init_result());
io_thread()->PostTaskAndWait(
FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
@@ -112,74 +98,6 @@ TEST_F(ChannelTest, InitShutdown) {
*mutable_channel() = nullptr;
}
-// ChannelTest.InitFails -------------------------------------------------------
-
-class MockRawChannelOnInitFails : public RawChannel {
- public:
- MockRawChannelOnInitFails() : on_init_called_(false) {}
- ~MockRawChannelOnInitFails() override {}
-
- // |RawChannel| public methods:
- size_t GetSerializedPlatformHandleSize() const override { return 0; }
-
- private:
- // |RawChannel| protected methods:
- IOResult Read(size_t*) override {
- CHECK(false);
- return IO_FAILED_UNKNOWN;
- }
- IOResult ScheduleRead() override {
- CHECK(false);
- return IO_FAILED_UNKNOWN;
- }
- embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles(
- size_t,
- const void*) override {
- CHECK(false);
- return embedder::ScopedPlatformHandleVectorPtr();
- }
- IOResult WriteNoLock(size_t*, size_t*) override {
- CHECK(false);
- return IO_FAILED_UNKNOWN;
- }
- IOResult ScheduleWriteNoLock() override {
- CHECK(false);
- return IO_FAILED_UNKNOWN;
- }
- bool OnInit() override {
- EXPECT_FALSE(on_init_called_);
- on_init_called_ = true;
- return false;
- }
- void OnShutdownNoLock(scoped_ptr<ReadBuffer>,
- scoped_ptr<WriteBuffer>) override {
- CHECK(false);
- }
-
- bool on_init_called_;
-
- DISALLOW_COPY_AND_ASSIGN(MockRawChannelOnInitFails);
-};
-
-TEST_F(ChannelTest, InitFails) {
- io_thread()->PostTaskAndWait(FROM_HERE,
- base::Bind(&ChannelTest::CreateChannelOnIOThread,
- base::Unretained(this)));
- ASSERT_TRUE(channel());
-
- ASSERT_TRUE(raw_channel());
- mutable_raw_channel()->reset(new MockRawChannelOnInitFails());
-
- io_thread()->PostTaskAndWait(
- FROM_HERE,
- base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
- EXPECT_EQ(TRISTATE_FALSE, init_result());
-
- // Should destroy |Channel| with no |Shutdown()| (on not-the-I/O-thread).
- EXPECT_TRUE(channel()->HasOneRef());
- *mutable_channel() = nullptr;
-}
-
// ChannelTest.CloseBeforeAttachAndRun -----------------------------------------
TEST_F(ChannelTest, CloseBeforeRun) {
@@ -191,7 +109,6 @@ TEST_F(ChannelTest, CloseBeforeRun) {
io_thread()->PostTaskAndWait(
FROM_HERE,
base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
- EXPECT_EQ(TRISTATE_TRUE, init_result());
scoped_refptr<ChannelEndpoint> channel_endpoint;
scoped_refptr<MessagePipe> mp(
@@ -219,7 +136,6 @@ TEST_F(ChannelTest, ShutdownAfterAttach) {
io_thread()->PostTaskAndWait(
FROM_HERE,
base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
- EXPECT_EQ(TRISTATE_TRUE, init_result());
scoped_refptr<ChannelEndpoint> channel_endpoint;
scoped_refptr<MessagePipe> mp(
@@ -262,7 +178,6 @@ TEST_F(ChannelTest, WaitAfterAttachRunAndShutdown) {
io_thread()->PostTaskAndWait(
FROM_HERE,
base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
- EXPECT_EQ(TRISTATE_TRUE, init_result());
scoped_refptr<ChannelEndpoint> channel_endpoint;
scoped_refptr<MessagePipe> mp(
diff --git a/mojo/edk/system/message_pipe_test_utils.cc b/mojo/edk/system/message_pipe_test_utils.cc
index ba6a0e0..f227543 100644
--- a/mojo/edk/system/message_pipe_test_utils.cc
+++ b/mojo/edk/system/message_pipe_test_utils.cc
@@ -74,7 +74,7 @@ void ChannelThread::InitChannelOnIOThread(
// Create and initialize |Channel|.
channel_ = new Channel(platform_support_);
- CHECK(channel_->Init(RawChannel::Create(platform_handle.Pass())));
+ channel_->Init(RawChannel::Create(platform_handle.Pass()));
// Start the bootstrap endpoint.
// Note: On the "server" (parent process) side, we need not attach/run the
diff --git a/mojo/edk/system/raw_channel.cc b/mojo/edk/system/raw_channel.cc
index aa9c95f..aff1110 100644
--- a/mojo/edk/system/raw_channel.cc
+++ b/mojo/edk/system/raw_channel.cc
@@ -171,7 +171,7 @@ RawChannel::~RawChannel() {
DCHECK(!weak_ptr_factory_.HasWeakPtrs());
}
-bool RawChannel::Init(Delegate* delegate) {
+void RawChannel::Init(Delegate* delegate) {
DCHECK(delegate);
DCHECK(!delegate_);
@@ -188,13 +188,7 @@ bool RawChannel::Init(Delegate* delegate) {
DCHECK(!write_buffer_);
write_buffer_.reset(new WriteBuffer(GetSerializedPlatformHandleSize()));
- if (!OnInit()) {
- delegate_ = nullptr;
- message_loop_for_io_ = nullptr;
- read_buffer_.reset();
- write_buffer_.reset();
- return false;
- }
+ OnInit();
IOResult io_result = ScheduleRead();
if (io_result != IO_PENDING) {
@@ -204,10 +198,8 @@ bool RawChannel::Init(Delegate* delegate) {
FROM_HERE, base::Bind(&RawChannel::OnReadCompleted,
weak_ptr_factory_.GetWeakPtr(), io_result, 0));
}
-
- // ScheduleRead() failure is treated as a read failure (by notifying the
- // delegate), not as an init failure.
- return true;
+ // Note: |ScheduleRead()| failure is treated as a read failure (by notifying
+ // the delegate), not an initialization failure.
}
void RawChannel::Shutdown() {
diff --git a/mojo/edk/system/raw_channel.h b/mojo/edk/system/raw_channel.h
index 62e13ff..f567767 100644
--- a/mojo/edk/system/raw_channel.h
+++ b/mojo/edk/system/raw_channel.h
@@ -87,9 +87,8 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// This must be called (on an I/O thread) before this object is used. Does
// *not* take ownership of |delegate|. Both the I/O thread and |delegate| must
// remain alive until |Shutdown()| is called (unless this fails); |delegate|
- // will no longer be used after |Shutdown()|. Returns true on success. On
- // failure, |Shutdown()| should *not* be called.
- bool Init(Delegate* delegate);
+ // will no longer be used after |Shutdown()|.
+ void Init(Delegate* delegate);
// This must be called (on the I/O thread) before this object is destroyed.
void Shutdown();
@@ -279,7 +278,7 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
virtual IOResult ScheduleWriteNoLock() = 0;
// Must be called on the I/O thread WITHOUT |write_lock_| held.
- virtual bool OnInit() = 0;
+ virtual void OnInit() = 0;
// On shutdown, passes the ownership of the buffers to subclasses, which may
// want to preserve them if there are pending read/write. Must be called on
// the I/O thread under |write_lock_|.
diff --git a/mojo/edk/system/raw_channel_posix.cc b/mojo/edk/system/raw_channel_posix.cc
index 71ec02f..078f8cb 100644
--- a/mojo/edk/system/raw_channel_posix.cc
+++ b/mojo/edk/system/raw_channel_posix.cc
@@ -54,7 +54,7 @@ class RawChannelPosix : public RawChannel,
IOResult WriteNoLock(size_t* platform_handles_written,
size_t* bytes_written) override;
IOResult ScheduleWriteNoLock() override;
- bool OnInit() override;
+ void OnInit() override;
void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
scoped_ptr<WriteBuffer> write_buffer) override;
@@ -310,7 +310,7 @@ RawChannel::IOResult RawChannelPosix::ScheduleWriteNoLock() {
return IO_FAILED_UNKNOWN;
}
-bool RawChannelPosix::OnInit() {
+void RawChannelPosix::OnInit() {
DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
DCHECK(!read_watcher_);
@@ -318,18 +318,12 @@ bool RawChannelPosix::OnInit() {
DCHECK(!write_watcher_);
write_watcher_.reset(new base::MessageLoopForIO::FileDescriptorWatcher());
- if (!message_loop_for_io()->WatchFileDescriptor(
- fd_.get().fd, true, base::MessageLoopForIO::WATCH_READ,
- read_watcher_.get(), this)) {
- // TODO(vtl): I'm not sure |WatchFileDescriptor()| actually fails cleanly
- // (in the sense of returning the message loop's state to what it was before
- // it was called).
- read_watcher_.reset();
- write_watcher_.reset();
- return false;
- }
-
- return true;
+ // I don't know how this can fail (unless |fd_| is bad, in which case it's a
+ // bug in our code). I also don't know if |WatchFileDescriptor()| actually
+ // fails cleanly.
+ CHECK(message_loop_for_io()->WatchFileDescriptor(
+ fd_.get().fd, true, base::MessageLoopForIO::WATCH_READ,
+ read_watcher_.get(), this));
}
void RawChannelPosix::OnShutdownNoLock(
diff --git a/mojo/edk/system/raw_channel_unittest.cc b/mojo/edk/system/raw_channel_unittest.cc
index 5f86e7e..a8cbcba 100644
--- a/mojo/edk/system/raw_channel_unittest.cc
+++ b/mojo/edk/system/raw_channel_unittest.cc
@@ -59,7 +59,7 @@ bool CheckMessageData(const void* bytes, uint32_t num_bytes) {
}
void InitOnIOThread(RawChannel* raw_channel, RawChannel::Delegate* delegate) {
- CHECK(raw_channel->Init(delegate));
+ raw_channel->Init(delegate);
}
bool WriteTestMessageToHandle(const embedder::PlatformHandle& handle,
diff --git a/mojo/edk/system/raw_channel_win.cc b/mojo/edk/system/raw_channel_win.cc
index 27b9ccf..7ec7ad7 100644
--- a/mojo/edk/system/raw_channel_win.cc
+++ b/mojo/edk/system/raw_channel_win.cc
@@ -168,7 +168,7 @@ class RawChannelWin : public RawChannel {
IOResult WriteNoLock(size_t* platform_handles_written,
size_t* bytes_written) override;
IOResult ScheduleWriteNoLock() override;
- bool OnInit() override;
+ void OnInit() override;
void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
scoped_ptr<WriteBuffer> write_buffer) override;
@@ -521,20 +521,19 @@ RawChannel::IOResult RawChannelWin::ScheduleWriteNoLock() {
return io_result;
}
-bool RawChannelWin::OnInit() {
+void RawChannelWin::OnInit() {
DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
DCHECK(handle_.is_valid());
- if (skip_completion_port_on_success_ &&
- !g_vista_or_higher_functions.Get().SetFileCompletionNotificationModes(
- handle_.get().handle, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
- return false;
+ if (skip_completion_port_on_success_) {
+ // I don't know how this can fail (unless |handle_| is bad, in which case
+ // it's a bug in our code).
+ CHECK(g_vista_or_higher_functions.Get().SetFileCompletionNotificationModes(
+ handle_.get().handle, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS));
}
DCHECK(!io_handler_);
io_handler_ = new RawChannelIOHandler(this, handle_.Pass());
-
- return true;
}
void RawChannelWin::OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
diff --git a/mojo/edk/system/remote_message_pipe_unittest.cc b/mojo/edk/system/remote_message_pipe_unittest.cc
index bf608fb..1860c23 100644
--- a/mojo/edk/system/remote_message_pipe_unittest.cc
+++ b/mojo/edk/system/remote_message_pipe_unittest.cc
@@ -127,8 +127,8 @@ class RemoteMessagePipeTest : public testing::Test {
CHECK(!channels_[channel_index]);
channels_[channel_index] = new Channel(&platform_support_);
- CHECK(channels_[channel_index]->Init(
- RawChannel::Create(platform_handles_[channel_index].Pass())));
+ channels_[channel_index]->Init(
+ RawChannel::Create(platform_handles_[channel_index].Pass()));
}
void BootstrapChannelEndpointsOnIOThread(scoped_refptr<ChannelEndpoint> ep0,
diff --git a/mojo/mojo_services_public.gyp b/mojo/mojo_services_public.gyp
index 975c46d..5c4885e 100644
--- a/mojo/mojo_services_public.gyp
+++ b/mojo/mojo_services_public.gyp
@@ -30,6 +30,9 @@
# GN version: //mojo/services/clipboard/public/interfaces
'target_name': 'mojo_clipboard_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/clipboard/public/interfaces/clipboard.mojom',
],
@@ -45,6 +48,9 @@
# GN version: //mojo/services/input_events/public/interfaces
'target_name': 'mojo_input_events_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/input_events/public/interfaces/input_event_constants.mojom',
'services/input_events/public/interfaces/input_events.mojom',
@@ -64,6 +70,9 @@
# GN version: //mojo/services/geometry/public/interfaces
'target_name': 'mojo_geometry_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/geometry/public/interfaces/geometry.mojom',
],
@@ -79,6 +88,9 @@
# GN version: //mojo/services/gpu/public/interfaces
'target_name': 'mojo_gpu_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/gpu/public/interfaces/command_buffer.mojom',
'services/gpu/public/interfaces/gpu.mojom',
@@ -99,6 +111,9 @@
# GN version: //mojo/services/native_viewport/public/interfaces
'target_name': 'mojo_native_viewport_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/native_viewport/public/interfaces/native_viewport.mojom',
],
@@ -122,6 +137,9 @@
# GN version: //mojo/services/navigation/public/interfaces
'target_name': 'mojo_navigation_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/navigation/public/interfaces/navigation.mojom',
],
@@ -138,6 +156,9 @@
# GN version: //mojo/services/content_handler/public/interfaces
'target_name': 'mojo_content_handler_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/content_handler/public/interfaces/content_handler.mojom',
],
@@ -155,7 +176,10 @@
# GN version: //mojo/services/network/public/interfaces
'target_name': 'mojo_network_bindings',
'type': 'static_library',
- 'sources': [
+ 'variables' : {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
+ 'sources': [
'services/network/public/interfaces/cookie_store.mojom',
'services/network/public/interfaces/net_address.mojom',
'services/network/public/interfaces/network_error.mojom',
@@ -187,6 +211,9 @@
# GN version: //mojo/services/view_manager/public/interfaces/
'target_name': 'mojo_view_manager_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/view_manager/public/interfaces/view_manager.mojom',
'services/view_manager/public/interfaces/view_manager_constants.mojom',
@@ -213,6 +240,9 @@
# GN version: //mojo/services/surfaces/public/interfaces
'target_name': 'mojo_surfaces_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/surfaces/public/interfaces/surfaces.mojom',
'services/surfaces/public/interfaces/surfaces_service.mojom',
@@ -235,6 +265,9 @@
# GN version: //mojo/services/surfaces/public/interfaces:surface_id
'target_name': 'mojo_surface_id_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/surfaces/public/interfaces/surface_id.mojom',
],
@@ -250,6 +283,9 @@
# GN version: //mojo/services/window_manager/public/interfaces
'target_name': 'mojo_window_manager_bindings',
'type': 'static_library',
+ 'variables': {
+ 'mojom_import_args': [ '-I<(DEPTH)', '-Iservices' ],
+ },
'sources': [
'services/window_manager/public/interfaces/window_manager.mojom',
],
diff --git a/mojo/public/VERSION b/mojo/public/VERSION
index c0e3c72..3ee95c5 100644
--- a/mojo/public/VERSION
+++ b/mojo/public/VERSION
@@ -1 +1 @@
-9fbbc4f0fef1187312316c0ed992342474e139f1 \ No newline at end of file
+b737c0531e299ad494725c518699843e76ff84f5
diff --git a/mojo/public/cpp/application/application_impl.h b/mojo/public/cpp/application/application_impl.h
index dbc8554d..0ea22c9 100644
--- a/mojo/public/cpp/application/application_impl.h
+++ b/mojo/public/cpp/application/application_impl.h
@@ -98,7 +98,8 @@ class ApplicationImpl : public InterfaceImpl<Application> {
// Application implementation.
void AcceptConnection(const String& requestor_url,
- ServiceProviderPtr provider) override;
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) override;
typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList;
diff --git a/mojo/public/cpp/application/lib/application_impl.cc b/mojo/public/cpp/application/lib/application_impl.cc
index 18c78b0..6677003 100644
--- a/mojo/public/cpp/application/lib/application_impl.cc
+++ b/mojo/public/cpp/application/lib/application_impl.cc
@@ -61,11 +61,13 @@ ApplicationImpl::~ApplicationImpl() {
ApplicationConnection* ApplicationImpl::ConnectToApplication(
const String& application_url) {
MOJO_CHECK(initialized_);
- ServiceProviderPtr out_service_provider;
- shell_->ConnectToApplication(application_url,
- GetProxy(&out_service_provider));
+ ServiceProviderPtr local_services;
+ InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services);
+ ServiceProviderPtr remote_services;
+ shell_->ConnectToApplication(application_url, GetProxy(&remote_services),
+ local_services.Pass());
internal::ServiceRegistry* registry = new internal::ServiceRegistry(
- this, application_url, out_service_provider.Pass());
+ this, application_url, remote_services.Pass(), local_request.Pass());
if (!delegate_->ConfigureOutgoingConnection(registry)) {
delete registry;
return nullptr;
@@ -99,10 +101,12 @@ void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) {
shell_.set_error_handler(shell_watch_);
}
-void ApplicationImpl::AcceptConnection(const String& requestor_url,
- ServiceProviderPtr service_provider) {
+void ApplicationImpl::AcceptConnection(
+ const String& requestor_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) {
internal::ServiceRegistry* registry = new internal::ServiceRegistry(
- this, requestor_url, service_provider.Pass());
+ this, requestor_url, exposed_services.Pass(), services.Pass());
if (!delegate_->ConfigureIncomingConnection(registry)) {
delete registry;
return;
diff --git a/mojo/public/cpp/application/lib/service_registry.cc b/mojo/public/cpp/application/lib/service_registry.cc
index 19a8be2..d934a16 100644
--- a/mojo/public/cpp/application/lib/service_registry.cc
+++ b/mojo/public/cpp/application/lib/service_registry.cc
@@ -11,16 +11,19 @@
namespace mojo {
namespace internal {
-ServiceRegistry::ServiceRegistry(ApplicationImpl* application_impl,
- const std::string& url,
- ServiceProviderPtr service_provider)
+ServiceRegistry::ServiceRegistry(
+ ApplicationImpl* application_impl,
+ const std::string& url,
+ ServiceProviderPtr remote_services,
+ InterfaceRequest<ServiceProvider> local_services)
: application_impl_(application_impl),
url_(url),
- remote_service_provider_(service_provider.Pass()) {
- remote_service_provider_.set_client(this);
+ local_binding_(this, local_services.Pass()),
+ remote_service_provider_(remote_services.Pass()) {
}
-ServiceRegistry::ServiceRegistry() : application_impl_(nullptr) {
+ServiceRegistry::ServiceRegistry()
+ : application_impl_(nullptr), local_binding_(this) {
}
ServiceRegistry::~ServiceRegistry() {
diff --git a/mojo/public/cpp/application/lib/service_registry.h b/mojo/public/cpp/application/lib/service_registry.h
index b02f63d..af1613b 100644
--- a/mojo/public/cpp/application/lib/service_registry.h
+++ b/mojo/public/cpp/application/lib/service_registry.h
@@ -25,7 +25,8 @@ class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
ServiceRegistry();
ServiceRegistry(ApplicationImpl* application_impl,
const std::string& url,
- ServiceProviderPtr service_provider);
+ ServiceProviderPtr remote_services,
+ InterfaceRequest<ServiceProvider> local_services);
~ServiceRegistry() override;
// ApplicationConnection overrides.
@@ -51,6 +52,7 @@ class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
typedef std::map<std::string, ServiceConnectorBase*>
NameToServiceConnectorMap;
NameToServiceConnectorMap name_to_service_connector_;
+ Binding<ServiceProvider> local_binding_;
ServiceProviderPtr remote_service_provider_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
diff --git a/mojo/public/cpp/bindings/array.h b/mojo/public/cpp/bindings/array.h
index 2544abb..ca4e9cc 100644
--- a/mojo/public/cpp/bindings/array.h
+++ b/mojo/public/cpp/bindings/array.h
@@ -20,7 +20,7 @@ namespace mojo {
template <typename T>
class Array {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(Array, RValue)
+ MOJO_MOVE_ONLY_TYPE(Array)
public:
typedef internal::ArrayTraits<T, internal::IsMoveOnlyType<T>::value> Traits;
typedef typename Traits::ConstRefType ConstRefType;
@@ -37,9 +37,9 @@ class Array {
}
~Array() { Traits::Finalize(&vec_); }
- Array(RValue other) : is_null_(true) { Take(other.object); }
- Array& operator=(RValue other) {
- Take(other.object);
+ Array(Array&& other) : is_null_(true) { Take(&other); }
+ Array& operator=(Array&& other) {
+ Take(&other);
return *this;
}
diff --git a/mojo/public/cpp/bindings/binding.h b/mojo/public/cpp/bindings/binding.h
index 72dbde3..4ecc6a8 100644
--- a/mojo/public/cpp/bindings/binding.h
+++ b/mojo/public/cpp/bindings/binding.h
@@ -26,14 +26,23 @@ namespace mojo {
//
// class FooImpl : public Foo {
// public:
-// explicit FooImpl(ScopedMessagePipeHandle handle)
-// : binding_(this, handle.Pass()) {}
+// explicit FooImpl(InterfaceRequest<Foo> request)
+// : binding_(this, request.Pass()) {}
//
// // Foo implementation here.
//
// private:
// Binding<Foo> binding_;
// };
+//
+// class MyFooFactory : public InterfaceFactory<Foo> {
+// public:
+// void Create(..., InterfaceRequest<Foo> request) override {
+// auto f = new FooImpl(request.Pass());
+// // Do something to manage the lifetime of |f|. Use StrongBinding<> to
+// // delete FooImpl on connection errors.
+// }
+// };
template <typename Interface>
class Binding : public ErrorHandler {
public:
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h
index c56e770..a2ede4d 100644
--- a/mojo/public/cpp/bindings/interface_ptr.h
+++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -18,16 +18,22 @@ class ErrorHandler;
// InterfacePtr represents a proxy to a remote instance of an interface.
template <typename Interface>
class InterfacePtr {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(InterfacePtr, RValue)
+ MOJO_MOVE_ONLY_TYPE(InterfacePtr)
public:
InterfacePtr() {}
+ InterfacePtr(decltype(nullptr)) {}
- InterfacePtr(RValue other) {
- internal_state_.Swap(&other.object->internal_state_);
+ InterfacePtr(InterfacePtr&& other) {
+ internal_state_.Swap(&other.internal_state_);
}
- InterfacePtr& operator=(RValue other) {
+ InterfacePtr& operator=(InterfacePtr&& other) {
+ reset();
+ internal_state_.Swap(&other.internal_state_);
+ return *this;
+ }
+
+ InterfacePtr& operator=(decltype(nullptr)) {
reset();
- internal_state_.Swap(&other.object->internal_state_);
return *this;
}
diff --git a/mojo/public/cpp/bindings/interface_request.h b/mojo/public/cpp/bindings/interface_request.h
index 0a6dc2c..1723330 100644
--- a/mojo/public/cpp/bindings/interface_request.h
+++ b/mojo/public/cpp/bindings/interface_request.h
@@ -12,13 +12,13 @@ namespace mojo {
// Used in methods that return instances of remote objects.
template <typename Interface>
class InterfaceRequest {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(InterfaceRequest, RValue)
+ MOJO_MOVE_ONLY_TYPE(InterfaceRequest)
public:
InterfaceRequest() {}
- InterfaceRequest(RValue other) { handle_ = other.object->handle_.Pass(); }
- InterfaceRequest& operator=(RValue other) {
- handle_ = other.object->handle_.Pass();
+ InterfaceRequest(InterfaceRequest&& other) { handle_ = other.handle_.Pass(); }
+ InterfaceRequest& operator=(InterfaceRequest&& other) {
+ handle_ = other.handle_.Pass();
return *this;
}
diff --git a/mojo/public/cpp/bindings/lib/filter_chain.cc b/mojo/public/cpp/bindings/lib/filter_chain.cc
index 6634562..d32eb78 100644
--- a/mojo/public/cpp/bindings/lib/filter_chain.cc
+++ b/mojo/public/cpp/bindings/lib/filter_chain.cc
@@ -14,14 +14,14 @@ namespace internal {
FilterChain::FilterChain(MessageReceiver* sink) : sink_(sink) {
}
-FilterChain::FilterChain(RValue other) : sink_(other.object->sink_) {
- other.object->sink_ = nullptr;
- filters_.swap(other.object->filters_);
+FilterChain::FilterChain(FilterChain&& other) : sink_(other.sink_) {
+ other.sink_ = nullptr;
+ filters_.swap(other.filters_);
}
-FilterChain& FilterChain::operator=(RValue other) {
- std::swap(sink_, other.object->sink_);
- filters_.swap(other.object->filters_);
+FilterChain& FilterChain::operator=(FilterChain&& other) {
+ std::swap(sink_, other.sink_);
+ filters_.swap(other.filters_);
return *this;
}
diff --git a/mojo/public/cpp/bindings/lib/filter_chain.h b/mojo/public/cpp/bindings/lib/filter_chain.h
index fc66642..bd7f9f5 100644
--- a/mojo/public/cpp/bindings/lib/filter_chain.h
+++ b/mojo/public/cpp/bindings/lib/filter_chain.h
@@ -15,17 +15,15 @@ namespace mojo {
namespace internal {
class FilterChain {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(FilterChain, RValue)
+ MOJO_MOVE_ONLY_TYPE(FilterChain)
public:
// Doesn't take ownership of |sink|. Therefore |sink| has to stay alive while
// this object is alive.
explicit FilterChain(MessageReceiver* sink = nullptr);
- // Move-only constructor and operator=.
- FilterChain(RValue other);
- FilterChain& operator=(RValue other);
-
+ FilterChain(FilterChain&& other);
+ FilterChain& operator=(FilterChain&& other);
~FilterChain();
template <typename FilterType>
diff --git a/mojo/public/cpp/bindings/map.h b/mojo/public/cpp/bindings/map.h
index 7aa7b6f..5149bb0 100644
--- a/mojo/public/cpp/bindings/map.h
+++ b/mojo/public/cpp/bindings/map.h
@@ -13,7 +13,8 @@ namespace mojo {
template <typename Key, typename Value>
class Map {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(Map, RValue)
+ MOJO_MOVE_ONLY_TYPE(Map)
+
public:
// Map keys can not be move only classes.
static_assert(!internal::IsMoveOnlyType<Key>::value,
@@ -45,9 +46,9 @@ class Map {
~Map() { Traits::Finalize(&map_); }
- Map(RValue other) : is_null_(true) { Take(other.object); }
- Map& operator=(RValue other) {
- Take(other.object);
+ Map(Map&& other) : is_null_(true) { Take(&other); }
+ Map& operator=(Map&& other) {
+ Take(&other);
return *this;
}
diff --git a/mojo/public/cpp/bindings/strong_binding.h b/mojo/public/cpp/bindings/strong_binding.h
index 73b43b3..0cd4f03 100644
--- a/mojo/public/cpp/bindings/strong_binding.h
+++ b/mojo/public/cpp/bindings/strong_binding.h
@@ -36,6 +36,13 @@ namespace mojo {
// StrongBinding<Foo> binding_;
// };
//
+// class MyFooFactory : public InterfaceFactory<Foo> {
+// public:
+// void Create(..., InterfaceRequest<Foo> request) override {
+// new StronglyBound(request.Pass()); // The binding now owns the
+// // instance of StronglyBound.
+// }
+// };
template <typename Interface>
class StrongBinding : public ErrorHandler {
public:
@@ -98,6 +105,7 @@ class StrongBinding : public ErrorHandler {
error_handler_ = error_handler;
}
+ Interface* impl() { return binding_.impl(); }
typename Interface::Client* client() { return binding_.client(); }
// Exposed for testing, should not generally be used.
internal::Router* internal_router() { return binding_.internal_router(); }
diff --git a/mojo/public/cpp/bindings/struct_ptr.h b/mojo/public/cpp/bindings/struct_ptr.h
index efcf255..a420fa5 100644
--- a/mojo/public/cpp/bindings/struct_ptr.h
+++ b/mojo/public/cpp/bindings/struct_ptr.h
@@ -27,16 +27,23 @@ class StructHelper {
template <typename Struct>
class StructPtr {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(StructPtr, RValue);
+ MOJO_MOVE_ONLY_TYPE(StructPtr)
public:
StructPtr() : ptr_(nullptr) {}
+ StructPtr(decltype(nullptr)) : ptr_(nullptr) {}
+
~StructPtr() { delete ptr_; }
- StructPtr(RValue other) : ptr_(nullptr) { Take(other.object); }
- StructPtr& operator=(RValue other) {
- Take(other.object);
+ StructPtr& operator=(decltype(nullptr)) {
+ reset();
+ return *this;
+ }
+
+ StructPtr(StructPtr&& other) : ptr_(nullptr) { Take(&other); }
+ StructPtr& operator=(StructPtr&& other) {
+ Take(&other);
return *this;
}
@@ -101,16 +108,23 @@ class StructPtr {
// Designed to be used when Struct is small and copyable.
template <typename Struct>
class InlinedStructPtr {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(InlinedStructPtr, RValue);
+ MOJO_MOVE_ONLY_TYPE(InlinedStructPtr);
public:
InlinedStructPtr() : is_null_(true) {}
+ InlinedStructPtr(decltype(nullptr)) : is_null_(true) {}
+
~InlinedStructPtr() {}
- InlinedStructPtr(RValue other) : is_null_(true) { Take(other.object); }
- InlinedStructPtr& operator=(RValue other) {
- Take(other.object);
+ InlinedStructPtr& operator=(decltype(nullptr)) {
+ reset();
+ return *this;
+ }
+
+ InlinedStructPtr(InlinedStructPtr&& other) : is_null_(true) { Take(&other); }
+ InlinedStructPtr& operator=(InlinedStructPtr&& other) {
+ Take(&other);
return *this;
}
diff --git a/mojo/public/cpp/bindings/tests/container_test_util.cc b/mojo/public/cpp/bindings/tests/container_test_util.cc
index 12fdaba..e8377c4 100644
--- a/mojo/public/cpp/bindings/tests/container_test_util.cc
+++ b/mojo/public/cpp/bindings/tests/container_test_util.cc
@@ -32,14 +32,14 @@ MoveOnlyType::MoveOnlyType() : moved_(false), ptr_(this) {
num_instances_++;
}
-MoveOnlyType::MoveOnlyType(RValue other)
- : moved_(true), ptr_(other.object->ptr()) {
+MoveOnlyType::MoveOnlyType(MoveOnlyType&& other)
+ : moved_(true), ptr_(other.ptr()) {
num_instances_++;
}
-MoveOnlyType& MoveOnlyType::operator=(RValue other) {
+MoveOnlyType& MoveOnlyType::operator=(MoveOnlyType&& other) {
moved_ = true;
- ptr_ = other.object->ptr();
+ ptr_ = other.ptr();
return *this;
}
diff --git a/mojo/public/cpp/bindings/tests/container_test_util.h b/mojo/public/cpp/bindings/tests/container_test_util.h
index 1c3e5ee..1e29d22 100644
--- a/mojo/public/cpp/bindings/tests/container_test_util.h
+++ b/mojo/public/cpp/bindings/tests/container_test_util.h
@@ -28,12 +28,12 @@ class CopyableType {
};
class MoveOnlyType {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(MoveOnlyType, RValue)
+ MOJO_MOVE_ONLY_TYPE(MoveOnlyType)
public:
typedef MoveOnlyType Data_;
MoveOnlyType();
- MoveOnlyType(RValue other);
- MoveOnlyType& operator=(RValue other);
+ MoveOnlyType(MoveOnlyType&& other);
+ MoveOnlyType& operator=(MoveOnlyType&& other);
~MoveOnlyType();
bool moved() const { return moved_; }
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
index 91ce84b..f90dc3d 100644
--- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -327,12 +327,8 @@ TEST_F(InterfacePtrTest, ReentrantWaitForIncomingMethodCall) {
sample::ServicePtr proxy;
ReentrantServiceImpl* impl = BindToProxy(new ReentrantServiceImpl(), &proxy);
- proxy->Frobinate(sample::FooPtr(),
- sample::Service::BAZ_OPTIONS_REGULAR,
- sample::PortPtr());
- proxy->Frobinate(sample::FooPtr(),
- sample::Service::BAZ_OPTIONS_REGULAR,
- sample::PortPtr());
+ proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr);
+ proxy->Frobinate(nullptr, sample::Service::BAZ_OPTIONS_REGULAR, nullptr);
PumpMessages();
diff --git a/mojo/public/cpp/bindings/tests/struct_unittest.cc b/mojo/public/cpp/bindings/tests/struct_unittest.cc
index 8f7580d..52d1313 100644
--- a/mojo/public/cpp/bindings/tests/struct_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/struct_unittest.cc
@@ -43,11 +43,21 @@ TEST_F(StructTest, Rect) {
EXPECT_TRUE(!rect);
EXPECT_FALSE(rect);
+ rect = nullptr;
+ EXPECT_TRUE(rect.is_null());
+ EXPECT_TRUE(!rect);
+ EXPECT_FALSE(rect);
+
rect = MakeRect();
EXPECT_FALSE(rect.is_null());
EXPECT_FALSE(!rect);
EXPECT_TRUE(rect);
+ RectPtr null_rect = nullptr;
+ EXPECT_TRUE(null_rect.is_null());
+ EXPECT_TRUE(!null_rect);
+ EXPECT_FALSE(null_rect);
+
CheckRect(*rect);
}
@@ -96,6 +106,20 @@ TEST_F(StructTest, Serialization_Basic) {
CheckRect(*rect2);
}
+// Construction of a struct with struct pointers from null.
+TEST_F(StructTest, Construction_StructPointers) {
+ RectPairPtr pair;
+ EXPECT_TRUE(pair.is_null());
+
+ pair = RectPair::New();
+ EXPECT_FALSE(pair.is_null());
+ EXPECT_TRUE(pair->first.is_null());
+ EXPECT_TRUE(pair->first.is_null());
+
+ pair = nullptr;
+ EXPECT_TRUE(pair.is_null());
+}
+
// Serialization test of a struct with struct pointers.
TEST_F(StructTest, Serialization_StructPointers) {
RectPairPtr pair(RectPair::New());
diff --git a/mojo/public/cpp/system/handle.h b/mojo/public/cpp/system/handle.h
index 211d895..0c5adc7 100644
--- a/mojo/public/cpp/system/handle.h
+++ b/mojo/public/cpp/system/handle.h
@@ -84,7 +84,7 @@ namespace mojo {
// like the C++11 |unique_ptr|.
template <class HandleType>
class ScopedHandleBase {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(ScopedHandleBase, RValue)
+ MOJO_MOVE_ONLY_TYPE(ScopedHandleBase)
public:
ScopedHandleBase() {}
@@ -96,11 +96,11 @@ class ScopedHandleBase {
: handle_(other.release()) {}
// Move-only constructor and operator=.
- ScopedHandleBase(RValue other) : handle_(other.object->release()) {}
- ScopedHandleBase& operator=(RValue other) {
- if (other.object != this) {
+ ScopedHandleBase(ScopedHandleBase&& other) : handle_(other.release()) {}
+ ScopedHandleBase& operator=(ScopedHandleBase&& other) {
+ if (&other != this) {
CloseIfNecessary();
- handle_ = other.object->release();
+ handle_ = other.release();
}
return *this;
}
diff --git a/mojo/public/cpp/system/macros.h b/mojo/public/cpp/system/macros.h
index 564b6be..f2bd0bc 100644
--- a/mojo/public/cpp/system/macros.h
+++ b/mojo/public/cpp/system/macros.h
@@ -29,21 +29,17 @@ char(&ArraySizeHelper(const T(&array)[N]))[N];
} // namespace mojo
#define MOJO_ARRAYSIZE(array) (sizeof(::mojo::ArraySizeHelper(array)))
-// Used to make a type move-only in C++03. See Chromium's base/move.h for more
-// details.
-#define MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
- private: \
- struct rvalue_type { \
- explicit rvalue_type(type* object) : object(object) {} \
- type* object; \
- }; \
- type(type&); \
- void operator=(type&); \
- \
- public: \
- operator rvalue_type() { return rvalue_type(this); } \
- type Pass() { return type(rvalue_type(this)); } \
- typedef void MoveOnlyTypeForCPP03; \
- \
+// Used to make a type move-only. See Chromium's base/move.h for more
+// details. The MoveOnlyTypeForCPP03 typedef is for Chromium's base/callback to
+// tell that this type is move-only.
+#define MOJO_MOVE_ONLY_TYPE(type) \
+ private: \
+ type(type&); \
+ void operator=(type&); \
+ \
+ public: \
+ type&& Pass() MOJO_WARN_UNUSED_RESULT { return static_cast<type&&>(*this); } \
+ typedef void MoveOnlyTypeForCPP03; \
+ \
private:
#endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
diff --git a/mojo/public/cpp/system/tests/macros_unittest.cc b/mojo/public/cpp/system/tests/macros_unittest.cc
index 89dd764..27a61bd 100644
--- a/mojo/public/cpp/system/tests/macros_unittest.cc
+++ b/mojo/public/cpp/system/tests/macros_unittest.cc
@@ -76,7 +76,7 @@ TEST(MacrosCppTest, ArraySize) {
// Note: MSVS is very strict (and arguably buggy) about warnings for classes
// defined in a local scope, so define these globally.
class MoveOnlyInt {
- MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(MoveOnlyInt, RValue)
+ MOJO_MOVE_ONLY_TYPE(MoveOnlyInt)
public:
MoveOnlyInt() : is_set_(false), value_() {}
@@ -84,12 +84,12 @@ class MoveOnlyInt {
~MoveOnlyInt() {}
// Move-only constructor and operator=.
- MoveOnlyInt(RValue other) { *this = other; }
- MoveOnlyInt& operator=(RValue other) {
- if (other.object != this) {
- is_set_ = other.object->is_set_;
- value_ = other.object->value_;
- other.object->is_set_ = false;
+ MoveOnlyInt(MoveOnlyInt&& other) { *this = other.Pass(); }
+ MoveOnlyInt& operator=(MoveOnlyInt&& other) {
+ if (&other != this) {
+ is_set_ = other.is_set_;
+ value_ = other.value_;
+ other.is_set_ = false;
}
return *this;
}
diff --git a/mojo/public/dart/core.dart b/mojo/public/dart/core.dart
index 15b5363..e9fb716 100644
--- a/mojo/public/dart/core.dart
+++ b/mojo/public/dart/core.dart
@@ -11,6 +11,7 @@ import 'dart:typed_data';
part 'src/buffer.dart';
part 'src/data_pipe.dart';
+part 'src/event_stream.dart';
part 'src/handle.dart';
part 'src/handle_watcher.dart';
part 'src/message_pipe.dart';
diff --git a/mojo/public/dart/src/buffer.dart b/mojo/public/dart/src/buffer.dart
index c0071b3..4467315 100644
--- a/mojo/public/dart/src/buffer.dart
+++ b/mojo/public/dart/src/buffer.dart
@@ -5,16 +5,16 @@
part of core;
class _MojoSharedBufferNatives {
- static List Create(int num_bytes, int flags)
+ static List Create(int numBytes, int flags)
native "MojoSharedBuffer_Create";
- static List Duplicate(int buffer_handle, int flags)
+ static List Duplicate(int bufferHandle, int flags)
native "MojoSharedBuffer_Duplicate";
static List Map(MojoSharedBuffer buffer,
- int buffer_handle,
+ int bufferHandle,
int offset,
- int num_bytes,
+ int numBytes,
int flags)
native "MojoSharedBuffer_Map";
@@ -32,14 +32,11 @@ class MojoSharedBuffer {
MojoResult status;
ByteData mapping;
- MojoSharedBuffer._() {
- handle = null;
- status = MojoResult.OK;
- mapping = null;
- }
+ MojoSharedBuffer(
+ this.handle, [this.status = MojoResult.OK, this.mapping = null]);
- factory MojoSharedBuffer(int num_bytes, [int flags = 0]) {
- List result = _MojoSharedBufferNatives.Create(num_bytes, flags);
+ factory MojoSharedBuffer.create(int numBytes, [int flags = 0]) {
+ List result = _MojoSharedBufferNatives.Create(numBytes, flags);
if (result == null) {
return null;
}
@@ -49,10 +46,8 @@ class MojoSharedBuffer {
return null;
}
- MojoSharedBuffer buf = new MojoSharedBuffer._();
- buf.status = r;
- buf.handle = new MojoHandle(result[1]);
- buf.mapping = null;
+ MojoSharedBuffer buf =
+ new MojoSharedBuffer(new MojoHandle(result[1]), r, null);
return buf;
}
@@ -67,10 +62,8 @@ class MojoSharedBuffer {
return null;
}
- MojoSharedBuffer dupe = new MojoSharedBuffer._();
- dupe.status = r;
- dupe.handle = new MojoHandle(result[1]);
- dupe.mapping = null; // The buffer is not mapped in the duplicate.
+ MojoSharedBuffer dupe =
+ new MojoSharedBuffer(new MojoHandle(result[1]), r, null);
return dupe;
}
@@ -85,13 +78,13 @@ class MojoSharedBuffer {
return status;
}
- MojoResult map(int offset, int num_bytes, [int flags = 0]) {
+ MojoResult map(int offset, int numBytes, [int flags = 0]) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
List result = _MojoSharedBufferNatives.Map(
- this, handle.h, offset, num_bytes, flags);
+ this, handle.h, offset, numBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
diff --git a/mojo/public/dart/src/client.dart b/mojo/public/dart/src/client.dart
index 9ae6be6..f8ec73c 100644
--- a/mojo/public/dart/src/client.dart
+++ b/mojo/public/dart/src/client.dart
@@ -4,135 +4,79 @@
part of bindings;
-abstract class Client {
- core.MojoMessagePipeEndpoint _endpoint;
- core.MojoEventStream _eventStream;
- List _sendQueue;
+abstract class Client extends core.MojoEventStreamListener {
Map<int, Completer> _completerMap;
- bool _isOpen = false;
int _nextId = 0;
- void handleResponse(ServiceMessage reader);
-
Client(core.MojoMessagePipeEndpoint endpoint) :
- _sendQueue = [],
_completerMap = {},
- _endpoint = endpoint,
- _eventStream = new core.MojoEventStream(endpoint.handle);
+ super(endpoint);
- Client.fromHandle(int handle) {
- _sendQueue = [];
- _completerMap = {};
- _endpoint =
- new core.MojoMessagePipeEndpoint(new core.MojoHandle(handle));
- _eventStream = new core.MojoHandle(_endpoint.handle);
- }
+ Client.fromHandle(core.MojoHandle handle) :
+ _completerMap = {},
+ super.fromHandle(handle);
+
+ Client.unbound() :
+ _completerMap = {},
+ super.unbound();
- void _doRead() {
+ void handleResponse(ServiceMessage reader);
+
+ void handleRead() {
// Query how many bytes are available.
- var result = _endpoint.query();
+ var result = endpoint.query();
assert(result.status.isOk || result.status.isResourceExhausted);
// Read the data.
var bytes = new ByteData(result.bytesRead);
var handles = new List<core.MojoHandle>(result.handlesRead);
- result = _endpoint.read(bytes, result.bytesRead, handles);
+ result = endpoint.read(bytes, result.bytesRead, handles);
assert(result.status.isOk || result.status.isResourceExhausted);
var message = new ServiceMessage.fromMessage(new Message(bytes, handles));
handleResponse(message);
}
- void _doWrite() {
- if (_sendQueue.length > 0) {
- List messageCompleter = _sendQueue.removeAt(0);
- ServiceMessage message = messageCompleter[0];
- Completer completer = messageCompleter[1];
- _endpoint.write(message.buffer,
- message.buffer.lengthInBytes,
- message.handles);
- if (!_endpoint.status.isOk) {
- throw "message pipe write failed";
- }
- if (completer != null) {
- if (!message.header.hasRequestId) {
- throw "Message has a completer, but does not expect a response";
- }
- int requestId = message.header.requestId;
- if (_completerMap[requestId] != null) {
- throw "Request Id $requestId is already in use.";
- }
- _completerMap[requestId] = completer;
- }
- }
- }
-
- void open() {
- _eventStream.listen((List<int> event) {
- var signalsWatched = new core.MojoHandleSignals(event[0]);
- var signalsReceived = new core.MojoHandleSignals(event[1]);
- if (signalsReceived.isPeerClosed) {
- close();
- return;
- }
-
- if (signalsReceived.isReadable) {
- _doRead();
- }
-
- if (signalsReceived.isWritable) {
- _doWrite();
- }
-
- if (_sendQueue.length == 0) {
- var withoutWritable = signalsWatched - core.MojoHandleSignals.WRITABLE;
- _eventStream.enableSignals(withoutWritable);
- } else {
- _eventStream.enableSignals(signalsWatched);
- }
- });
- _isOpen = true;
+ void handleWrite() {
+ throw 'Unexpected write signal in client.';
}
- void close() {
- if (_isOpen) {
- _eventStream.close();
- _eventStream = null;
- _isOpen = false;
+ void sendMessage(Struct message, int name) {
+ if (!isOpen) {
+ listen();
}
- }
-
- void enqueueMessage(Struct message, int name) {
var header = new MessageHeader(name);
var serviceMessage = message.serializeWithHeader(header);
- _sendQueue.add([serviceMessage, null]);
- if (_sendQueue.length == 1) {
- _eventStream.enableAllEvents();
+ endpoint.write(serviceMessage.buffer,
+ serviceMessage.buffer.lengthInBytes,
+ serviceMessage.handles);
+ if (!endpoint.status.isOk) {
+ throw "message pipe write failed";
}
}
- int _getNextId() {
- return _nextId++;
- }
-
- Future enqueueMessageWithRequestId(
+ Future sendMessageWithRequestId(
Struct message, int name, int id, int flags) {
+ if (!isOpen) {
+ listen();
+ }
if (id == -1) {
- id = _getNextId();
+ id = _nextId++;
}
var header = new MessageHeader.withRequestId(name, flags, id);
var serviceMessage = message.serializeWithHeader(header);
- var completer = new Completer();
- _sendQueue.add([serviceMessage, completer]);
- if (_sendQueue.length == 1) {
- _eventStream.enableAllEvents();
- } else {
- _eventStream.enableReadEvents();
+ endpoint.write(serviceMessage.buffer,
+ serviceMessage.buffer.lengthInBytes,
+ serviceMessage.handles);
+ if (!endpoint.status.isOk) {
+ throw "message pipe write failed";
}
+
+ var completer = new Completer();
+ _completerMap[id] = completer;
return completer.future;
}
// Need a getter for this for access in subclasses.
Map<int, Completer> get completerMap => _completerMap;
- bool get isOpen => _isOpen;
}
diff --git a/mojo/public/dart/src/codec.dart b/mojo/public/dart/src/codec.dart
index 8969ea1..d5f5b90 100644
--- a/mojo/public/dart/src/codec.dart
+++ b/mojo/public/dart/src/codec.dart
@@ -138,6 +138,42 @@ class Encoder {
}
}
+ void encodeMessagePipeHandle(
+ core.MojoMessagePipeEndpoint value, int offset, bool nullable) =>
+ encodeHandle(value != null ? value.handle : null, offset, nullable);
+
+ void encodeConsumerHandle(
+ core.MojoDataPipeConsumer value, int offset, bool nullable) =>
+ encodeHandle(value != null ? value.handle : null, offset, nullable);
+
+ void encodeProducerHandle(
+ core.MojoDataPipeProducer value, int offset, bool nullable) =>
+ encodeHandle(value != null ? value.handle : null, offset, nullable);
+
+ void encodeSharedBufferHandle(
+ core.MojoSharedBuffer value, int offset, bool nullable) =>
+ encodeHandle(value != null ? value.handle : null, offset, nullable);
+
+ void encodeInterface(Interface interface, int offset, bool nullable) {
+ if (interface == null) {
+ encodeInvalideHandle(offset, nullable);
+ return;
+ }
+ var pipe = new core.MojoMessagePipe();
+ interface.bind(pipe.endpoints[0]);
+ encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable);
+ }
+
+ void encodeInterfaceRequest(Client client, int offset, bool nullable) {
+ if (client == null) {
+ encodeInvalideHandle(offset, nullable);
+ return;
+ }
+ var pipe = new core.MojoMessagePipe();
+ client.bind(pipe.endpoints[0]);
+ encodeMessagePipeHandle(pipe.endpoints[1], offset, nullable);
+ }
+
void encodeNullPointer(int offset, bool nullable) {
if (!nullable) {
throw 'Trying to encode a null pointer for a non-nullable type';
@@ -271,10 +307,11 @@ class Encoder {
encodeArray((e, v) => e.appendDoubleArray(v),
8, value, offset, nullability, expectedLength);
- void encodeHandleArray(List<core.MojoHandle> value,
- int offset,
- int nullability,
- int expectedLength) {
+ void _handleArrayEncodeHelper(Function elementEncoder,
+ List value,
+ int offset,
+ int nullability,
+ int expectedLength) {
if (value == null) {
encodeNullPointer(offset, isArrayNullable(nullability));
return;
@@ -283,11 +320,74 @@ class Encoder {
kSerializedHandleSize, value.length, offset, expectedLength);
for (int i = 0; i < value.length; ++i) {
int handleOffset = DataHeader.kHeaderSize + kSerializedHandleSize * i;
- encoder.encodeHandle(
- value[i], handleOffset, isElementNullable(nullability));
+ elementEncoder(
+ encoder, value[i], handleOffset, isElementNullable(nullability));
}
}
+ void encodeHandleArray(
+ List<core.MojoHandle> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeHandle(v, o, n),
+ value, offset, nullability, expectedLength);
+
+ void encodeMessagePipeHandleArray(
+ List<core.MojoMessagePipeEndpoint> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeMessagePipeHandle(v, o, n),
+ value, offset, nullability, expectedLength);
+
+ void encodeConsumerHandleArray(
+ List<core.MojoDataPipeConsumer> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeConsumerHandle(v, o, n),
+ value, offset, nullability, expectedLength);
+
+ void encodeProducerHandleArray(
+ List<core.MojoDataPipeProducer> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeProducerHandle(v, o, n),
+ value, offset, nullability, expectedLength);
+
+ void encodeSharedBufferHandleArray(
+ List<core.MojoSharedBuffer> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeSharedBufferHandle(v, o, n),
+ value, offset, nullability, expectedLength);
+
+ void encodeInterfaceRequestArray(
+ List<Client> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeInterfaceRequest(v, o, n),
+ value, offset, nullability, expectedLength);
+
+ void encodeInterfaceArray(
+ List<Interface> value,
+ int offset,
+ int nullability,
+ int expectedLength) =>
+ _handleArrayEncodeHelper(
+ (e, v, o, n) => e.encodeInterface(v, o, n),
+ value, offset, nullability, expectedLength);
+
static Uint8List _utf8OfString(String s) =>
(new Uint8List.fromList((const Utf8Encoder()).convert(s)));
@@ -346,6 +446,7 @@ class Encoder {
}
}
+
class Decoder {
Message _message;
int _base = 0;
@@ -393,6 +494,31 @@ class Decoder {
return _handles[index];
}
+ core.MojoMessagePipeEndpoint decodeMessagePipeHandle(
+ int offset, bool nullable) =>
+ new core.MojoMessagePipeEndpoint(decodeHandle(offset, nullable));
+
+ core.MojoDataPipeConsumer decodeConsumerHandle(int offset, bool nullable) =>
+ new core.MojoDataPipeConsumer(decodeHandle(offset, nullable));
+
+ core.MojoDataPipeProducer decodeProducerHandle(int offset, bool nullable) =>
+ new core.MojoDataPipeProducer(decodeHandle(offset, nullable));
+
+ core.MojoSharedBuffer decodeSharedBufferHandle(int offset, bool nullable) =>
+ new core.MojoSharedBuffer(decodeHandle(offset, nullable));
+
+ Client decodeServiceInterface(
+ int offset, bool nullable, Function clientFactory) {
+ var endpoint = decodeMessagePipeHandle(offset, nullable);
+ return endpoint.handle.isValid ? clientFactory(endpoint) : null;
+ }
+
+ Interface decodeInterfaceRequest(
+ int offset, bool nullable, Function interfaceFactory) {
+ var endpoint = decodeMessagePipeHandle(offset, nullable);
+ return endpoint.handle.isValid ? interfaceFactory(endpoint) : null;
+ }
+
Decoder decodePointer(int offset, bool nullable) {
int basePosition = _base + offset;
int pointerOffset = decodeUint64(offset);
@@ -528,22 +654,69 @@ class Decoder {
decodeArray((b, s, l) => new Float64List.view(b, s, l),
8, offset, nullability, expectedLength);
- List<core.MojoHandle> decodeHandleArray(
- int offset, int nullability, int expectedLength) {
+ List _handleArrayDecodeHelper(Function elementDecoder,
+ int offset,
+ int nullability,
+ int expectedLength) {
Decoder d = decodePointer(offset, isArrayNullable(nullability));
if (d == null) {
return null;
}
var header = d.decodeDataHeaderForArray(4, expectedLength);
- var result = new core.MojoHandle(header.numFields);
+ var result = new List(header.numFields);
for (int i = 0; i < result.length; ++i) {
- result[i] = d.decodeHandle(
+ result[i] = elementDecoder(
+ d,
DataHeader.kHeaderSize + kSerializedHandleSize * i,
isElementNullable(nullability));
}
return result;
+
}
+ List<core.MojoHandle> decodeHandleArray(
+ int offset, int nullability, int expectedLength) =>
+ _handleArrayDecodeHelper((d, o, n) => d.decodeHandle(o, n),
+ offset, nullability, expectedLength);
+
+ List<core.MojoDataPipeConsumer> decodeConsumerHandleArray(
+ int offset, int nullability, int expectedLength) =>
+ _handleArrayDecodeHelper((d, o, n) => d.decodeConsumerHandle(o, n),
+ offset, nullability, expectedLength);
+
+ List<core.MojoDataPipeProducer> decodeProducerHandleArray(
+ int offset, int nullability, int expectedLength) =>
+ _handleArrayDecodeHelper((d, o, n) => d.decodeProducerHandle(o, n),
+ offset, nullability, expectedLength);
+
+ List<core.MojoMessagePipeEndpoint> decodeMessagePipeHandleArray(
+ int offset, int nullability, int expectedLength) =>
+ _handleArrayDecodeHelper((d, o, n) => d.decodeMessagePipeHandle(o, n),
+ offset, nullability, expectedLength);
+
+ List<core.MojoSharedBuffer> decodeSharedBufferHandleArray(
+ int offset, int nullability, int expectedLength) =>
+ _handleArrayDecodeHelper((d, o, n) => d.decodeSharedBufferHandle(o, n),
+ offset, nullability, expectedLength);
+
+ List<Interface> decodeInterfaceRequestArray(
+ int offset,
+ int nullability,
+ int expectedLength,
+ Function interfaceFactory) =>
+ _handleArrayDecodeHelper(
+ (d, o, n) => d.decodeInterfaceRequest(o, n, interfaceFactory),
+ offset, nullability, expectedLength);
+
+ List<Client> decodeServiceInterfaceArray(
+ int offset,
+ int nullability,
+ int expectedLength,
+ Function clientFactory) =>
+ _handleArrayDecodeHelper(
+ (d, o, n) => d.decodeServiceInterface(o, n, clientFactory),
+ offset, nullability, expectedLength);
+
static String _stringOfUtf8(Uint8List bytes) =>
(const Utf8Decoder()).convert(bytes.toList());
diff --git a/mojo/public/dart/src/data_pipe.dart b/mojo/public/dart/src/data_pipe.dart
index 44acee9..7f3b3eb 100644
--- a/mojo/public/dart/src/data_pipe.dart
+++ b/mojo/public/dart/src/data_pipe.dart
@@ -7,25 +7,25 @@ part of core;
class _MojoDataPipeNatives {
static List MojoCreateDataPipe(
- int element_bytes, int capacity_bytes, int flags)
+ int elementBytes, int capacityBytes, int flags)
native "MojoDataPipe_Create";
- static List MojoWriteData(int handle, ByteData data, int num_bytes, int flags)
+ static List MojoWriteData(int handle, ByteData data, int numBytes, int flags)
native "MojoDataPipe_WriteData";
- static List MojoBeginWriteData(int handle, int buffer_bytes, int flags)
+ static List MojoBeginWriteData(int handle, int bufferBytes, int flags)
native "MojoDataPipe_BeginWriteData";
- static int MojoEndWriteData(int handle, int bytes_written)
+ static int MojoEndWriteData(int handle, int bytesWritten)
native "MojoDataPipe_EndWriteData";
- static List MojoReadData(int handle, ByteData data, int num_bytes, int flags)
+ static List MojoReadData(int handle, ByteData data, int numBytes, int flags)
native "MojoDataPipe_ReadData";
- static List MojoBeginReadData(int handle, int buffer_bytes, int flags)
+ static List MojoBeginReadData(int handle, int bufferBytes, int flags)
native "MojoDataPipe_BeginReadData";
- static int MojoEndReadData(int handle, int bytes_read)
+ static int MojoEndReadData(int handle, int bytesRead)
native "MojoDataPipe_EndReadData";
}
@@ -36,21 +36,20 @@ class MojoDataPipeProducer {
MojoHandle handle;
MojoResult status;
- final int element_bytes;
+ final int elementBytes;
- MojoDataPipeProducer(this.handle,
- this.status,
- this.element_bytes);
+ MojoDataPipeProducer(
+ this.handle, [this.status = MojoResult.OK, this.elementBytes = 1]);
- int write(ByteData data, [int num_bytes = -1, int flags = 0]) {
+ int write(ByteData data, [int numBytes = -1, int flags = 0]) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- int data_num_bytes = (num_bytes == -1) ? data.lengthInBytes : num_bytes;
+ int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes;
List result = _MojoDataPipeNatives.MojoWriteData(
- handle.h, data, data_num_bytes, flags);
+ handle.h, data, data_numBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
@@ -61,14 +60,14 @@ class MojoDataPipeProducer {
return result[1];
}
- ByteData beginWrite(int buffer_bytes, [int flags = 0]) {
+ ByteData beginWrite(int bufferBytes, [int flags = 0]) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
}
List result = _MojoDataPipeNatives.MojoBeginWriteData(
- handle.h, buffer_bytes, flags);
+ handle.h, bufferBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
@@ -79,12 +78,12 @@ class MojoDataPipeProducer {
return result[1];
}
- MojoResult endWrite(int bytes_written) {
+ MojoResult endWrite(int bytesWritten) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- int result = _MojoDataPipeNatives.MojoEndWriteData(handle.h, bytes_written);
+ int result = _MojoDataPipeNatives.MojoEndWriteData(handle.h, bytesWritten);
status = new MojoResult(result);
return status;
}
@@ -100,20 +99,20 @@ class MojoDataPipeConsumer {
MojoHandle handle;
MojoResult status;
- final int element_bytes;
+ final int elementBytes;
MojoDataPipeConsumer(
- this.handle, [this.status = MojoResult.OK, this.element_bytes = 1]);
+ this.handle, [this.status = MojoResult.OK, this.elementBytes = 1]);
- int read(ByteData data, [int num_bytes = -1, int flags = 0]) {
+ int read(ByteData data, [int numBytes = -1, int flags = 0]) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- int data_num_bytes = (num_bytes == -1) ? data.lengthInBytes : num_bytes;
+ int data_numBytes = (numBytes == -1) ? data.lengthInBytes : numBytes;
List result = _MojoDataPipeNatives.MojoReadData(
- handle.h, data, data_num_bytes, flags);
+ handle.h, data, data_numBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
@@ -123,14 +122,14 @@ class MojoDataPipeConsumer {
return result[1];
}
- ByteData beginRead([int buffer_bytes = 0, int flags = 0]) {
+ ByteData beginRead([int bufferBytes = 0, int flags = 0]) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
}
List result = _MojoDataPipeNatives.MojoBeginReadData(
- handle.h, buffer_bytes, flags);
+ handle.h, bufferBytes, flags);
if (result == null) {
status = MojoResult.INVALID_ARGUMENT;
return null;
@@ -141,12 +140,12 @@ class MojoDataPipeConsumer {
return result[1];
}
- MojoResult endRead(int bytes_read) {
+ MojoResult endRead(int bytesRead) {
if (handle == null) {
status = MojoResult.INVALID_ARGUMENT;
return status;
}
- int result = _MojoDataPipeNatives.MojoEndReadData(handle.h, bytes_read);
+ int result = _MojoDataPipeNatives.MojoEndReadData(handle.h, bytesRead);
status = new MojoResult(result);
return status;
}
@@ -171,22 +170,22 @@ class MojoDataPipe {
status = MojoResult.OK;
}
- factory MojoDataPipe([int element_bytes = DEFAULT_ELEMENT_SIZE,
- int capacity_bytes = DEFAULT_CAPACITY,
+ factory MojoDataPipe([int elementBytes = DEFAULT_ELEMENT_SIZE,
+ int capacityBytes = DEFAULT_CAPACITY,
int flags = FLAG_NONE]) {
List result = _MojoDataPipeNatives.MojoCreateDataPipe(
- element_bytes, capacity_bytes, flags);
+ elementBytes, capacityBytes, flags);
if (result == null) {
return null;
}
assert((result is List) && (result.length == 3));
- MojoHandle producer_handle = new MojoHandle(result[1]);
- MojoHandle consumer_handle = new MojoHandle(result[2]);
+ MojoHandle producerHandle = new MojoHandle(result[1]);
+ MojoHandle consumerHandle = new MojoHandle(result[2]);
MojoDataPipe pipe = new MojoDataPipe._internal();
pipe.producer = new MojoDataPipeProducer(
- producer_handle, new MojoResult(result[0]), element_bytes);
+ producerHandle, new MojoResult(result[0]), elementBytes);
pipe.consumer = new MojoDataPipeConsumer(
- consumer_handle, new MojoResult(result[0]), element_bytes);
+ consumerHandle, new MojoResult(result[0]), elementBytes);
pipe.status = new MojoResult(result[0]);
return pipe;
}
diff --git a/mojo/public/dart/src/event_stream.dart b/mojo/public/dart/src/event_stream.dart
new file mode 100644
index 0000000..797f0e6
--- /dev/null
+++ b/mojo/public/dart/src/event_stream.dart
@@ -0,0 +1,207 @@
+// Copyright 2014 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.
+
+part of core;
+
+class MojoEventStream extends Stream<int> {
+ // The underlying Mojo handle.
+ MojoHandle _handle;
+
+ // Providing our own stream controller allows us to take custom actions when
+ // listeners pause/resume/etc. their StreamSubscription.
+ StreamController _controller;
+
+ // The send port that we give to the handle watcher to notify us of handle
+ // events.
+ SendPort _sendPort;
+
+ // The receive port on which we listen and receive events from the handle
+ // watcher.
+ ReceivePort _receivePort;
+
+ // The signals on this handle that we're interested in.
+ MojoHandleSignals _signals;
+
+ // Whether listen has been called.
+ bool _isListening;
+
+ MojoEventStream(MojoHandle handle,
+ [MojoHandleSignals signals = MojoHandleSignals.READABLE]) :
+ _handle = handle,
+ _signals = signals,
+ _isListening = false {
+ MojoResult result = MojoHandle.register(this);
+ if (!result.isOk) {
+ throw "Failed to register the MojoHandle: $result.";
+ }
+ }
+
+ void close() {
+ if (_handle != null) {
+ MojoHandleWatcher.close(_handle);
+ _handle = null;
+ }
+ if (_receivePort != null) {
+ _receivePort.close();
+ _receivePort = null;
+ }
+ }
+
+ StreamSubscription<List<int>> listen(
+ void onData(List event),
+ {Function onError, void onDone(), bool cancelOnError}) {
+ if (_isListening) {
+ throw "Listen has already been called: $_handle.";
+ }
+ _receivePort = new ReceivePort();
+ _sendPort = _receivePort.sendPort;
+ _controller = new StreamController(sync: true,
+ onListen: _onSubscriptionStateChange,
+ onCancel: _onSubscriptionStateChange,
+ onPause: _onPauseStateChange,
+ onResume: _onPauseStateChange);
+ _controller.addStream(_receivePort);
+
+ if (_signals != MojoHandleSignals.NONE) {
+ var res = MojoHandleWatcher.add(_handle, _sendPort, _signals.value);
+ if (!res.isOk) {
+ throw "MojoHandleWatcher add failed: $res";
+ }
+ }
+
+ _isListening = true;
+ return _controller.stream.listen(
+ onData,
+ onError: onError,
+ onDone: onDone,
+ cancelOnError: cancelOnError);
+ }
+
+ void enableSignals(MojoHandleSignals signals) {
+ _signals = signals;
+ if (_isListening) {
+ var res = MojoHandleWatcher.add(_handle, _sendPort, signals.value);
+ if (!res.isOk) {
+ throw "MojoHandleWatcher add failed: $res";
+ }
+ }
+ }
+
+ void enableReadEvents() => enableSignals(MojoHandleSignals.READABLE);
+ void enableWriteEvents() => enableSignals(MojoHandleSignals.WRITABLE);
+ void enableAllEvents() => enableSignals(MojoHandleSignals.READWRITE);
+
+ void _onSubscriptionStateChange() {
+ if (!_controller.hasListener) {
+ close();
+ }
+ }
+
+ void _onPauseStateChange() {
+ if (_controller.isPaused) {
+ var res = MojoHandleWatcher.remove(_handle);
+ if (!res.isOk) {
+ throw "MojoHandleWatcher add failed: $res";
+ }
+ } else {
+ var res = MojoHandleWatcher.add(_handle, _sendPort, _signals.value);
+ if (!res.isOk) {
+ throw "MojoHandleWatcher add failed: $res";
+ }
+ }
+ }
+
+ bool get readyRead => _handle.readyRead;
+ bool get readyWrite => _handle.readyWrite;
+
+ String toString() => "$_handle";
+}
+
+
+class MojoEventStreamListener {
+ MojoMessagePipeEndpoint _endpoint;
+ MojoEventStream _eventStream;
+ bool _isOpen = false;
+ bool _isInHandler = false;
+
+ MojoEventStreamListener(MojoMessagePipeEndpoint endpoint) :
+ _endpoint = endpoint,
+ _eventStream = new MojoEventStream(endpoint.handle),
+ _isOpen = false;
+
+ MojoEventStreamListener.fromHandle(MojoHandle handle) {
+ _endpoint = new MojoMessagePipeEndpoint(handle);
+ _eventStream = new MojoEventStream(handle);
+ _isOpen = false;
+ }
+
+ MojoEventStreamListener.unbound() :
+ _endpoint = null,
+ _eventStream = null,
+ _isOpen = false;
+
+ void bind(MojoMessagePipeEndpoint endpoint) {
+ assert(!isBound);
+ _endpoint = endpoint;
+ _eventStream = new MojoEventStream(endpoint.handle);
+ _isOpen = false;
+ }
+
+ void bindFromHandle(MojoHandle handle) {
+ assert(!isBound);
+ _endpoint = new MojoMessagePipeEndpoint(handle);
+ _eventStream = new MojoEventStream(handle);
+ _isOpen = false;
+ }
+
+ StreamSubscription<int> listen() {
+ _isOpen = true;
+ return _eventStream.listen((List<int> event) {
+ var signalsWatched = new MojoHandleSignals(event[0]);
+ var signalsReceived = new MojoHandleSignals(event[1]);
+ if (signalsReceived.isPeerClosed) {
+ handlePeerClosed();
+ // The peer being closed obviates any other signal we might
+ // have received since we won't be able to read or write the handle.
+ // Thus, we just return before invoking other handlers.
+ return;
+ }
+ _isInHandler = true;
+ if (signalsReceived.isReadable) {
+ assert(_eventStream.readyRead);
+ handleRead();
+ }
+ if (signalsReceived.isWritable) {
+ assert(_eventStream.readyWrite);
+ handleWrite();
+ }
+ _eventStream.enableSignals(enableSignals(
+ signalsWatched, signalsReceived));
+ _isInHandler = false;
+ });
+ }
+
+ void close() {
+ if (_isOpen) {
+ _eventStream.close();
+ _isOpen = false;
+ _eventStream = null;
+ _endpoint = null;
+ }
+ }
+
+ void handleRead() {}
+ void handleWrite() {}
+ void handlePeerClosed() {
+ close();
+ }
+
+ MojoHandleSignals enableSignals(MojoHandleSignals watched,
+ MojoHandleSignals received) => watched;
+
+ MojoMessagePipeEndpoint get endpoint => _endpoint;
+ bool get isOpen => _isOpen;
+ bool get isInHandler => _isInHandler;
+ bool get isBound => _endpoint != null;
+}
diff --git a/mojo/public/dart/src/handle.dart b/mojo/public/dart/src/handle.dart
index f983815..a819804 100644
--- a/mojo/public/dart/src/handle.dart
+++ b/mojo/public/dart/src/handle.dart
@@ -72,118 +72,3 @@ class MojoHandle {
return h == other.h;
}
}
-
-
-class MojoEventStream extends Stream<int> {
- // The underlying Mojo handle.
- MojoHandle _handle;
-
- // Providing our own stream controller allows us to take custom actions when
- // listeners pause/resume/etc. their StreamSubscription.
- StreamController _controller;
-
- // The send port that we give to the handle watcher to notify us of handle
- // events.
- SendPort _sendPort;
-
- // The receive port on which we listen and receive events from the handle
- // watcher.
- ReceivePort _receivePort;
-
- // The signals on this handle that we're interested in.
- MojoHandleSignals _signals;
-
- // Whether listen has been called.
- bool _isListening;
-
- MojoEventStream(MojoHandle handle,
- [MojoHandleSignals signals = MojoHandleSignals.READABLE]) :
- _handle = handle,
- _signals = signals,
- _isListening = false {
- MojoResult result = MojoHandle.register(this);
- if (!result.isOk) {
- throw "Failed to register the MojoHandle: $result.";
- }
- }
-
- void close() {
- if (_handle != null) {
- MojoHandleWatcher.close(_handle);
- _handle = null;
- }
- if (_receivePort != null) {
- _receivePort.close();
- _receivePort = null;
- }
- }
-
- StreamSubscription<List<int>> listen(
- void onData(List event),
- {Function onError, void onDone(), bool cancelOnError}) {
- if (_isListening) {
- throw "Listen has already been called: $_handle.";
- }
- _receivePort = new ReceivePort();
- _sendPort = _receivePort.sendPort;
- _controller = new StreamController(sync: true,
- onListen: _onSubscriptionStateChange,
- onCancel: _onSubscriptionStateChange,
- onPause: _onPauseStateChange,
- onResume: _onPauseStateChange);
- _controller.addStream(_receivePort);
-
- if (_signals != MojoHandleSignals.NONE) {
- var res = MojoHandleWatcher.add(_handle, _sendPort, _signals.value);
- if (!res.isOk) {
- throw "MojoHandleWatcher add failed: $res";
- }
- }
-
- _isListening = true;
- return _controller.stream.listen(
- onData,
- onError: onError,
- onDone: onDone,
- cancelOnError: cancelOnError);
- }
-
- void enableSignals(MojoHandleSignals signals) {
- _signals = signals;
- if (_isListening) {
- var res = MojoHandleWatcher.add(_handle, _sendPort, signals.value);
- if (!res.isOk) {
- throw "MojoHandleWatcher add failed: $res";
- }
- }
- }
-
- void enableReadEvents() => enableSignals(MojoHandleSignals.READABLE);
- void enableWriteEvents() => enableSignals(MojoHandleSignals.WRITABLE);
- void enableAllEvents() => enableSignals(MojoHandleSignals.READWRITE);
-
- void _onSubscriptionStateChange() {
- if (!_controller.hasListener) {
- close();
- }
- }
-
- void _onPauseStateChange() {
- if (_controller.isPaused) {
- var res = MojoHandleWatcher.remove(_handle);
- if (!res.isOk) {
- throw "MojoHandleWatcher add failed: $res";
- }
- } else {
- var res = MojoHandleWatcher.add(_handle, _sendPort, _signals.value);
- if (!res.isOk) {
- throw "MojoHandleWatcher add failed: $res";
- }
- }
- }
-
- bool get readyRead => _handle.readyRead;
- bool get readyWrite => _handle.readyWrite;
-
- String toString() => "$_handle";
-}
diff --git a/mojo/public/dart/src/interface.dart b/mojo/public/dart/src/interface.dart
index 2069b52..0e73214 100644
--- a/mojo/public/dart/src/interface.dart
+++ b/mojo/public/dart/src/interface.dart
@@ -4,102 +4,75 @@
part of bindings;
-abstract class Interface {
- core.MojoMessagePipeEndpoint _endpoint;
- core.MojoEventStream _eventStream;
- List _sendQueue;
- bool _isOpen;
+abstract class Interface extends core.MojoEventStreamListener {
+ int _outstandingResponseFutures = 0;
+ bool _isClosing = false;
- Future<Message> handleMessage(ServiceMessage message);
+ Interface(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
- Interface(core.MojoMessagePipeEndpoint endpoint) :
- _endpoint = endpoint,
- _sendQueue = [],
- _eventStream = new core.MojoEventStream(endpoint.handle),
- _isOpen = false;
-
- Interface.fromHandle(int handle) {
- _endpoint =
- new core.MojoMessagePipeEndpoint(new core.MojoHandle(handle));
- _sendQueue = [];
- _eventStream = new core.MojoEventStream(_endpoint.handle);
- _isOpen = false;
- }
+ Interface.fromHandle(core.MojoHandle handle) : super.fromHandle(handle);
- void _doRead() {
- assert(_eventStream.readyRead);
+ Interface.unbound() : super.unbound();
+ Future<Message> handleMessage(ServiceMessage message);
+
+ void handleRead() {
// Query how many bytes are available.
- var result = _endpoint.query();
+ var result = endpoint.query();
assert(result.status.isOk || result.status.isResourceExhausted);
// Read the data and view as a message.
var bytes = new ByteData(result.bytesRead);
var handles = new List<core.MojoHandle>(result.handlesRead);
- result = _endpoint.read(bytes, result.bytesRead, handles);
+ result = endpoint.read(bytes, result.bytesRead, handles);
assert(result.status.isOk || result.status.isResourceExhausted);
// Prepare the response.
var message = new ServiceMessage.fromMessage(new Message(bytes, handles));
- var responseFuture = handleMessage(message);
+ var responseFuture = _isClosing ? null : handleMessage(message);
- // If there's a response, queue it up for sending.
+ // If there's a response, send it.
if (responseFuture != null) {
+ _outstandingResponseFutures++;
responseFuture.then((response) {
- _sendQueue.add(response);
- if (_sendQueue.length == 1) {
- _eventStream.enableWriteEvents();
+ _outstandingResponseFutures--;
+ if (isOpen) {
+ endpoint.write(response.buffer,
+ response.buffer.lengthInBytes,
+ response.handles);
+ if (!endpoint.status.isOk) {
+ throw "message pipe write failed: ${endpoint.status}";
+ }
+ if (_isClosing && (_outstandingResponseFutures == 0)) {
+ // This was the final response future for which we needed to send
+ // a response. It is safe to close.
+ super.close();
+ _isClosing = false;
+ }
}
});
+ } else if (_isClosing && (_outstandingResponseFutures == 0)) {
+ // We are closing, there is no response to send for this message, and
+ // there are no outstanding response futures. Do the close now.
+ super.close();
+ _isClosing = false;
}
}
- void _doWrite() {
- if (_sendQueue.length > 0) {
- assert(_eventStream.readyWrite);
- var responseMessage = _sendQueue.removeAt(0);
- _endpoint.write(responseMessage.buffer,
- responseMessage.buffer.lengthInBytes,
- responseMessage.handles);
- if (!_endpoint.status.isOk) {
- throw "message pipe write failed: ${_endpoint.status}";
- }
- }
- }
-
- StreamSubscription<int> listen() {
- _isOpen = true;
- return _eventStream.listen((List<int> event) {
- var signalsWatched = new core.MojoHandleSignals(event[0]);
- var signalsReceived = new core.MojoHandleSignals(event[1]);
- if (signalsReceived.isPeerClosed) {
- close();
- return;
- }
-
- if (signalsReceived.isReadable) {
- _doRead();
- }
-
- if (signalsReceived.isWritable) {
- _doWrite();
- }
-
- if (_sendQueue.length == 0) {
- var withoutWritable = signalsWatched - core.MojoHandleSignals.WRITABLE;
- _eventStream.enableSignals(withoutWritable);
- } else {
- _eventStream.enableSignals(signalsWatched);
- }
- });
+ void handleWrite() {
+ throw 'Unexpected write signal in client.';
}
void close() {
- // TODO(zra): Cancel outstanding Futures started in _doRead?
- if (_isOpen) {
- _eventStream.close();
- _isOpen = false;
- _eventStream = null;
+ if (!isOpen) return;
+ if (isInHandler || (_outstandingResponseFutures > 0)) {
+ // Either close() is being called from within handleRead() or
+ // handleWrite(), or close() is being called while there are outstanding
+ // response futures. Defer the actual close until all response futures
+ // have been resolved.
+ _isClosing = true;
+ } else {
+ super.close();
}
}
@@ -113,18 +86,18 @@ abstract class Interface {
return response.serializeWithHeader(header);
}
- void enqueueMessage(Struct message, int name) {
+ void sendMessage(Struct message, int name) {
var header = new MessageHeader(name);
var serviceMessage = message.serializeWithHeader(header);
- _sendQueue.add(serviceMessage);
- _eventStream.enableWriteEvents();
+ endpoint.write(serviceMessage.buffer,
+ serviceMessage.buffer.lengthInBytes,
+ serviceMessage.handles);
+ if (!endpoint.status.isOk) {
+ throw "message pipe write failed: ${endpoint.status}";
+ }
}
- Future enqueueMessageWithRequestId(Struct response, int name, int id) {
- // TODO(zra): Is this correct?
+ Future sendMessageWithRequestId(Struct response, int name, int id) {
throw "The client interface should not expect a response";
}
-
- bool get isOpen => _isOpen;
- core.MojoMessagePipeEndpoint get endpoint => _endpoint;
}
diff --git a/mojo/public/interfaces/application/application.mojom b/mojo/public/interfaces/application/application.mojom
index 4cf2110..d389ae2 100644
--- a/mojo/public/interfaces/application/application.mojom
+++ b/mojo/public/interfaces/application/application.mojom
@@ -12,5 +12,13 @@ interface Application {
// Initialize is guaranteed to be called before any AcceptConnection calls.
Initialize(array<string>? args);
- AcceptConnection(string? requestor_url, ServiceProvider? provider);
+ // Called in response to a call to mojo.Shell.ConnectToApplication().
+ // The |services| and |exposed_services| parameters are the same as those on
+ // mojo.Shell.ConnectToApplication().
+ // |services| will be used to look up services provided by this application.
+ // |exposed_services| can be used to look up services exposed by the
+ // application at |requestor_url|.
+ AcceptConnection(string requestor_url,
+ ServiceProvider&? services,
+ ServiceProvider? exposed_services);
};
diff --git a/mojo/public/interfaces/application/service_provider.mojom b/mojo/public/interfaces/application/service_provider.mojom
index fe0100b..b862d35 100644
--- a/mojo/public/interfaces/application/service_provider.mojom
+++ b/mojo/public/interfaces/application/service_provider.mojom
@@ -10,5 +10,5 @@ module mojo;
interface ServiceProvider {
// Connect the given message pipe handle to the named service. If the named
// service does not exist, then the handle will be closed.
- ConnectToService(string? interface_name, handle<message_pipe>? pipe);
+ ConnectToService(string interface_name, handle<message_pipe> pipe);
};
diff --git a/mojo/public/interfaces/application/shell.mojom b/mojo/public/interfaces/application/shell.mojom
index 3cc90fc..1adf1e6 100644
--- a/mojo/public/interfaces/application/shell.mojom
+++ b/mojo/public/interfaces/application/shell.mojom
@@ -11,7 +11,11 @@ import "mojo/public/interfaces/application/service_provider.mojom";
// it's Shell interface to connect to other Applications.
[Client=Application]
interface Shell {
- // Loads url. mojo:{service} will result in the user of the value of the
+ // Loads |application_url|. mojo:{service} will result in the user of the value of the
// --origin flag to the shell being used.
- ConnectToApplication(string? application_url, ServiceProvider&? provider);
+ // |services| can be used to look up services provided by the application at |application_url|.
+ // |exposed_services| can be used to expose services to the application at |application_url|.
+ ConnectToApplication(string application_url,
+ ServiceProvider&? services,
+ ServiceProvider? exposed_services);
};
diff --git a/mojo/public/js/codec.js b/mojo/public/js/codec.js
index 68d5dba..357e507 100644
--- a/mojo/public/js/codec.js
+++ b/mojo/public/js/codec.js
@@ -125,7 +125,7 @@ define("mojo/public/js/codec", [
};
Decoder.prototype.decodeHandle = function() {
- return this.handles[this.readUint32()];
+ return this.handles[this.readUint32()] || null;
};
Decoder.prototype.decodeString = function() {
diff --git a/mojo/public/js/connector.js b/mojo/public/js/connector.js
index 6578a0e..78ed963 100644
--- a/mojo/public/js/connector.js
+++ b/mojo/public/js/connector.js
@@ -19,7 +19,8 @@ define("mojo/public/js/connector", [
this.readWaitCookie_ = null;
this.errorHandler_ = null;
- this.waitToReadMore_();
+ if (handle)
+ this.waitToReadMore_();
}
Connector.prototype.close = function() {
diff --git a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
index 288bfd8..d9fee1c 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl
@@ -3,9 +3,8 @@ const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}};
{%- endfor %}
abstract class {{interface|name}}Calls {
- void enqueueMessage(bindings.Struct message, int name);
- Future enqueueMessageWithRequestId(bindings.Struct message, int name, int id);
- bool get isOpen;
+ void sendMessage(bindings.Struct message, int name);
+ Future sendMessageWithRequestId(bindings.Struct message, int name, int id);
{%- for method in interface.methods %}
{%- if method.response_parameters == None %}
@@ -15,12 +14,11 @@ abstract class {{interface|name}}Calls {
{%- endfor -%}
{%- set request_struct = method|struct_from_method %}
) {
- assert(isOpen);
var params = new {{request_struct|name}}();
{%- for parameter in method.parameters %}
params.{{parameter|name}} = {{parameter|name}};
{%- endfor %}
- enqueueMessage(params, k{{interface|name}}_{{method|name}}_name);
+ sendMessage(params, k{{interface|name}}_{{method|name}}_name);
}
{% else %}
{%- set response_struct = method|response_struct_from_method %}
@@ -31,12 +29,11 @@ abstract class {{interface|name}}Calls {
{%- set request_struct = method|struct_from_method %}
[int requestId = -1]
) {
- assert(isOpen);
var params = new {{request_struct|name}}();
{%- for parameter in method.parameters %}
params.{{parameter|name}} = {{parameter|name}};
{%- endfor %}
- return enqueueMessageWithRequestId(
+ return sendMessageWithRequestId(
params,
k{{interface|name}}_{{method|name}}_name,
requestId,
@@ -49,7 +46,14 @@ abstract class {{interface|name}}Calls {
class {{interface|name}}Client extends bindings.Client with {{interface|name}}Calls {
{{interface|name}}Client(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
- {{interface|name}}Client.fromHandle(int handle) : super.fromHandle(handle);
+ {{interface|name}}Client.fromHandle(core.MojoHandle handle) :
+ super.fromHandle(handle);
+
+ {{interface|name}}Client.unbound() : super.unbound();
+
+ static {{interface|name}}Client newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) =>
+ new {{interface|name}}Client(endpoint);
void handleResponse(bindings.ServiceMessage message) {
switch (message.header.type) {
@@ -76,13 +80,22 @@ class {{interface|name}}Client extends bindings.Client with {{interface|name}}Ca
}
-abstract class {{interface|name}}Interface extends bindings.Interface
+class {{interface|name}}Interface extends bindings.Interface
{% if interface.client != None -%}
with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Calls
{% endif -%} {
+ {{interface|name}}Interface _delegate = null;
+
{{interface|name}}Interface(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
- {{interface|name}}Interface.fromHandle(int handle) : super.fromHandle(handle);
+ {{interface|name}}Interface.fromHandle(core.MojoHandle handle) :
+ super.fromHandle(handle);
+
+ {{interface|name}}Interface.unbound() : super.unbound();
+
+ static {{interface|name}}Interface newFromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint) =>
+ new {{interface|name}}Interface(endpoint);
static const String name = '{{namespace|replace(".","::")}}::{{interface|name}}';
@@ -92,14 +105,26 @@ with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Cal
{%- for parameter in method.parameters -%}
{{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
{%- endfor -%}
- );
+ ) {
+ assert(_delegate != null);
+ _delegate.{{method|name}}(
+ {%- for parameter in method.parameters -%}
+ {{parameter|name}}{% if not loop.last %}, {% endif %}
+ {%- endfor %});
+ }
{%- else %}
{%- set response_struct = method|response_struct_from_method %}
Future<{{response_struct|name}}> {{method|name}}(
{%- for parameter in method.parameters -%}
{{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %}
{%- endfor -%}
- );
+ ) {
+ assert(_delegate != null);
+ return _delegate.{{method|name}}(
+ {%- for parameter in method.parameters -%}
+ {{parameter|name}}{% if not loop.last %}, {% endif %}
+ {%- endfor %});
+ }
{%- endif %}
{%- endfor %}
@@ -139,6 +164,12 @@ with {{imported_from[interface.client]}}{{interface.client|upper_camel_case}}Cal
}
return null;
}
+
+ {{interface|name}}Interface get delegate => _delegate;
+ set delegate({{interface|name}}Interface d) {
+ assert(_delegate == null);
+ _delegate = d;
+ }
}
diff --git a/mojo/public/tools/bindings/generators/mojom_dart_generator.py b/mojo/public/tools/bindings/generators/mojom_dart_generator.py
index 9fcdde8..893e665 100644
--- a/mojo/public/tools/bindings/generators/mojom_dart_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_dart_generator.py
@@ -51,15 +51,15 @@ _kind_to_dart_decl_type = {
mojom.UINT32: "int",
mojom.FLOAT: "double",
mojom.HANDLE: "core.MojoHandle",
- mojom.DCPIPE: "core.MojoHandle",
- mojom.DPPIPE: "core.MojoHandle",
- mojom.MSGPIPE: "core.MojoHandle",
- mojom.SHAREDBUFFER: "core.MojoHandle",
+ mojom.DCPIPE: "core.MojoDataPipeConsumer",
+ mojom.DPPIPE: "core.MojoDataPipeProducer",
+ mojom.MSGPIPE: "core.MojoMessagePipeEndpoint",
+ mojom.SHAREDBUFFER: "core.MojoSharedBuffer",
mojom.NULLABLE_HANDLE: "core.MojoHandle",
- mojom.NULLABLE_DCPIPE: "core.MojoHandle",
- mojom.NULLABLE_DPPIPE: "core.MojoHandle",
- mojom.NULLABLE_MSGPIPE: "core.MojoHandle",
- mojom.NULLABLE_SHAREDBUFFER: "core.MojoHandle",
+ mojom.NULLABLE_DCPIPE: "core.MojoDataPipeConsumer",
+ mojom.NULLABLE_DPPIPE: "core.MojoDataPipeProducer",
+ mojom.NULLABLE_MSGPIPE: "core.MojoMessagePipeEndpoint",
+ mojom.NULLABLE_SHAREDBUFFER: "core.MojoSharedBuffer",
mojom.INT64: "int",
mojom.UINT64: "int",
mojom.DOUBLE: "double",
@@ -78,14 +78,14 @@ _spec_to_decode_method = {
mojom.INT32.spec: 'decodeInt32',
mojom.INT64.spec: 'decodeInt64',
mojom.INT8.spec: 'decodeInt8',
- mojom.MSGPIPE.spec: 'decodeHandle',
- mojom.NULLABLE_DCPIPE.spec: 'decodeHandle',
- mojom.NULLABLE_DPPIPE.spec: 'decodeHandle',
+ mojom.MSGPIPE.spec: 'decodeMessagePipeHandle',
+ mojom.NULLABLE_DCPIPE.spec: 'decodeConsumerHandle',
+ mojom.NULLABLE_DPPIPE.spec: 'decodeProducerHandle',
mojom.NULLABLE_HANDLE.spec: 'decodeHandle',
- mojom.NULLABLE_MSGPIPE.spec: 'decodeHandle',
- mojom.NULLABLE_SHAREDBUFFER.spec: 'decodeHandle',
+ mojom.NULLABLE_MSGPIPE.spec: 'decodeMessagePipeHandle',
+ mojom.NULLABLE_SHAREDBUFFER.spec: 'decodeSharedBufferHandle',
mojom.NULLABLE_STRING.spec: 'decodeString',
- mojom.SHAREDBUFFER.spec: 'decodeHandle',
+ mojom.SHAREDBUFFER.spec: 'decodeSharedBufferHandle',
mojom.STRING.spec: 'decodeString',
mojom.UINT16.spec: 'decodeUint16',
mojom.UINT32.spec: 'decodeUint32',
@@ -104,14 +104,14 @@ _spec_to_encode_method = {
mojom.INT32.spec: 'encodeInt32',
mojom.INT64.spec: 'encodeInt64',
mojom.INT8.spec: 'encodeInt8',
- mojom.MSGPIPE.spec: 'encodeHandle',
- mojom.NULLABLE_DCPIPE.spec: 'encodeHandle',
- mojom.NULLABLE_DPPIPE.spec: 'encodeHandle',
+ mojom.MSGPIPE.spec: 'encodeMessagePipeHandle',
+ mojom.NULLABLE_DCPIPE.spec: 'encodeConsumerHandle',
+ mojom.NULLABLE_DPPIPE.spec: 'encodeProducerHandle',
mojom.NULLABLE_HANDLE.spec: 'encodeHandle',
- mojom.NULLABLE_MSGPIPE.spec: 'encodeHandle',
- mojom.NULLABLE_SHAREDBUFFER.spec: 'encodeHandle',
+ mojom.NULLABLE_MSGPIPE.spec: 'encodeMessagePipeHandle',
+ mojom.NULLABLE_SHAREDBUFFER.spec: 'encodeSharedBufferHandle',
mojom.NULLABLE_STRING.spec: 'encodeString',
- mojom.SHAREDBUFFER.spec: 'encodeHandle',
+ mojom.SHAREDBUFFER.spec: 'encodeSharedBufferHandle',
mojom.STRING.spec: 'encodeString',
mojom.UINT16.spec: 'encodeUint16',
mojom.UINT32.spec: 'encodeUint32',
@@ -140,7 +140,7 @@ def DartDefaultValue(field):
return "null"
if mojom.IsInterfaceKind(field.kind) or \
mojom.IsInterfaceRequestKind(field.kind):
- return _kind_to_dart_default_value[mojom.MSGPIPE]
+ return "null"
if mojom.IsEnumKind(field.kind):
return "0"
@@ -158,7 +158,7 @@ def DartDeclType(kind):
return "Map<"+ key_type + ", " + value_type + ">"
if mojom.IsInterfaceKind(kind) or \
mojom.IsInterfaceRequestKind(kind):
- return _kind_to_dart_decl_type[mojom.MSGPIPE]
+ return "Object"
if mojom.IsEnumKind(kind):
return "int"
@@ -242,7 +242,29 @@ def GetArrayNullabilityFlags(kind):
flags_to_set = [NOTHING_NULLABLE]
return ' | '.join(flags_to_set)
-def AppendEncodeDecodeParams(initial_params, kind, bit):
+def AppendDecodeParams(initial_params, kind, bit):
+ """ Appends standard parameters for decode calls. """
+ params = list(initial_params)
+ if (kind == mojom.BOOL):
+ params.append(str(bit))
+ if mojom.IsReferenceKind(kind):
+ if mojom.IsArrayKind(kind):
+ params.append(GetArrayNullabilityFlags(kind))
+ else:
+ params.append(GetDartTrueFalse(mojom.IsNullableKind(kind)))
+ if mojom.IsInterfaceKind(kind):
+ params.append('%sClient.newFromEndpoint' % GetDartType(kind))
+ if mojom.IsArrayKind(kind) and mojom.IsInterfaceKind(kind.kind):
+ params.append('%sClient.newFromEndpoint' % GetDartType(kind.kind))
+ if mojom.IsInterfaceRequestKind(kind):
+ params.append('%sInterface.newFromEndpoint' % GetDartType(kind.kind))
+ if mojom.IsArrayKind(kind) and mojom.IsInterfaceRequestKind(kind.kind):
+ params.append('%sInterface.newFromEndpoint' % GetDartType(kind.kind.kind))
+ if mojom.IsArrayKind(kind):
+ params.append(GetArrayExpectedLength(kind))
+ return params
+
+def AppendEncodeParams(initial_params, kind, bit):
""" Appends standard parameters shared between encode and decode calls. """
params = list(initial_params)
if (kind == mojom.BOOL):
@@ -263,12 +285,12 @@ def DecodeMethod(kind, offset, bit):
if mojom.IsEnumKind(kind):
return _DecodeMethodName(mojom.INT32)
if mojom.IsInterfaceRequestKind(kind):
- return 'decodeHandle'
+ return 'decodeInterfaceRequest'
if mojom.IsInterfaceKind(kind):
- return 'decodeHandle'
+ return 'decodeServiceInterface'
return _spec_to_decode_method[kind.spec]
methodName = _DecodeMethodName(kind)
- params = AppendEncodeDecodeParams([ str(offset) ], kind, bit)
+ params = AppendDecodeParams([ str(offset) ], kind, bit)
return '%s(%s)' % (methodName, ', '.join(params))
def EncodeMethod(kind, variable, offset, bit):
@@ -280,12 +302,12 @@ def EncodeMethod(kind, variable, offset, bit):
if mojom.IsEnumKind(kind):
return _EncodeMethodName(mojom.INT32)
if mojom.IsInterfaceRequestKind(kind):
- return 'encodeHandle'
+ return 'encodeInterfaceRequest'
if mojom.IsInterfaceKind(kind):
- return 'encodeHandle'
+ return 'encodeInterface'
return _spec_to_encode_method[kind.spec]
methodName = _EncodeMethodName(kind)
- params = AppendEncodeDecodeParams([ variable, str(offset) ], kind, bit)
+ params = AppendEncodeParams([ variable, str(offset) ], kind, bit)
return '%s(%s)' % (methodName, ', '.join(params))
def TranslateConstants(token):
diff --git a/mojo/public/tools/bindings/mojom.gni b/mojo/public/tools/bindings/mojom.gni
index d0de67a..d267fc92 100644
--- a/mojo/public/tools/bindings/mojom.gni
+++ b/mojo/public/tools/bindings/mojom.gni
@@ -35,6 +35,9 @@ import("../../mojo_sdk.gni")
# Mojo public SDK. These deps will be added as ordinary public deps
# rebased to the current directory.
#
+# import_dirs (optional)
+# List of import directories that will get added when processing sources.
+#
# testonly (optional)
#
# visibility (optional)
@@ -168,6 +171,15 @@ template("mojom") {
"-o",
rebase_path(root_gen_dir),
]
+
+ if (defined(invoker.import_dirs)) {
+ foreach(import_dir, invoker.import_dirs) {
+ args += [
+ "-I",
+ rebase_path(import_dir, root_build_dir),
+ ]
+ }
+ }
}
source_set(target_name) {
diff --git a/mojo/public/tools/download_shell_binary.py b/mojo/public/tools/download_shell_binary.py
index 2a0890c..b46139e 100755
--- a/mojo/public/tools/download_shell_binary.py
+++ b/mojo/public/tools/download_shell_binary.py
@@ -10,23 +10,24 @@ import sys
import tempfile
import zipfile
-current_path = os.path.dirname(os.path.realpath(__file__))
-sys.path.insert(0, os.path.join(current_path, "..", "..", "..", "tools"))
-# pylint: disable=F0401
-import find_depot_tools
-
if not sys.platform.startswith("linux"):
print "Not supported for your platform"
sys.exit(0)
-prebuilt_file_path = os.path.join(current_path, "prebuilt")
-stamp_path = os.path.join(prebuilt_file_path, "VERSION")
-depot_tools_path = find_depot_tools.add_depot_tools_to_path()
-gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
+def download(tools_directory):
+ current_path = os.path.dirname(os.path.realpath(__file__))
+ find_depot_tools_path = os.path.join(current_path, tools_directory)
+ sys.path.insert(0, find_depot_tools_path)
+ # pylint: disable=F0401
+ import find_depot_tools
+
+ prebuilt_file_path = os.path.join(current_path, "prebuilt")
+ stamp_path = os.path.join(prebuilt_file_path, "VERSION")
+ depot_tools_path = find_depot_tools.add_depot_tools_to_path()
+ gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
-def download():
version_path = os.path.join(current_path, "../VERSION")
with open(version_path) as version_file:
version = version_file.read().strip()
@@ -83,8 +84,18 @@ def download():
def main():
parser = argparse.ArgumentParser(description="Download mojo_shell binary "
"from google storage")
- parser.parse_args()
- return download()
+ parser.add_argument("--tools-directory",
+ dest="tools_directory",
+ metavar="<tools-directory>",
+ type=str,
+ help="Path to the directory containing"
+ " find_depot_tools.py, specified as a relative path"
+ " from the location of this file.")
+ args = parser.parse_args()
+ if not args.tools_directory:
+ print "Must specify --tools_directory; please see help message."
+ sys.exit(1)
+ return download(args.tools_directory)
if __name__ == "__main__":
sys.exit(main())
diff --git a/mojo/services/accessibility/public/interfaces/BUILD.gn b/mojo/services/accessibility/public/interfaces/BUILD.gn
index 3b5b4db..7997908c 100644
--- a/mojo/services/accessibility/public/interfaces/BUILD.gn
+++ b/mojo/services/accessibility/public/interfaces/BUILD.gn
@@ -10,6 +10,8 @@ mojom("interfaces") {
"accessibility.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
deps = [
"../../../geometry/public/interfaces",
]
diff --git a/mojo/services/accessibility/public/interfaces/accessibility.mojom b/mojo/services/accessibility/public/interfaces/accessibility.mojom
index 48fec82..3958388 100644
--- a/mojo/services/accessibility/public/interfaces/accessibility.mojom
+++ b/mojo/services/accessibility/public/interfaces/accessibility.mojom
@@ -4,7 +4,7 @@
module mojo;
-import "../../../geometry/public/interfaces/geometry.mojom";
+import "geometry/public/interfaces/geometry.mojom";
interface AxProvider {
GetTree() => (array<AxNode> nodes);
diff --git a/mojo/services/content_handler/public/interfaces/BUILD.gn b/mojo/services/content_handler/public/interfaces/BUILD.gn
index 78725c7..cb38d83 100644
--- a/mojo/services/content_handler/public/interfaces/BUILD.gn
+++ b/mojo/services/content_handler/public/interfaces/BUILD.gn
@@ -10,6 +10,8 @@ mojom("interfaces") {
"content_handler.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
deps = [
"../../../network/public/interfaces",
]
diff --git a/mojo/services/content_handler/public/interfaces/content_handler.mojom b/mojo/services/content_handler/public/interfaces/content_handler.mojom
index bf60240..c56410e 100644
--- a/mojo/services/content_handler/public/interfaces/content_handler.mojom
+++ b/mojo/services/content_handler/public/interfaces/content_handler.mojom
@@ -5,7 +5,7 @@
module mojo;
import "mojo/public/interfaces/application/shell.mojom";
-import "../../../network/public/interfaces/url_loader.mojom";
+import "network/public/interfaces/url_loader.mojom";
interface ContentHandler {
StartApplication(Shell shell, URLResponse response);
diff --git a/mojo/services/gpu/public/interfaces/BUILD.gn b/mojo/services/gpu/public/interfaces/BUILD.gn
index e1b7334..52723ac 100644
--- a/mojo/services/gpu/public/interfaces/BUILD.gn
+++ b/mojo/services/gpu/public/interfaces/BUILD.gn
@@ -13,7 +13,9 @@ mojom("interfaces") {
"viewport_parameter_listener.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
deps = [
- "//mojo/services/geometry/public/interfaces",
+ "../../../geometry/public/interfaces",
]
}
diff --git a/mojo/services/gpu/public/interfaces/command_buffer.mojom b/mojo/services/gpu/public/interfaces/command_buffer.mojom
index f071c68..a31b3dd 100644
--- a/mojo/services/gpu/public/interfaces/command_buffer.mojom
+++ b/mojo/services/gpu/public/interfaces/command_buffer.mojom
@@ -4,7 +4,7 @@
module mojo;
-import "mojo/services/gpu/public/interfaces/gpu_capabilities.mojom";
+import "gpu/public/interfaces/gpu_capabilities.mojom";
struct CommandBufferState {
int32 num_entries;
diff --git a/mojo/services/gpu/public/interfaces/gpu.mojom b/mojo/services/gpu/public/interfaces/gpu.mojom
index 5ac99bf..c61869c 100644
--- a/mojo/services/gpu/public/interfaces/gpu.mojom
+++ b/mojo/services/gpu/public/interfaces/gpu.mojom
@@ -4,9 +4,9 @@
module mojo;
-import "mojo/services/geometry/public/interfaces/geometry.mojom";
-import "mojo/services/gpu/public/interfaces/command_buffer.mojom";
-import "mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "gpu/public/interfaces/command_buffer.mojom";
+import "gpu/public/interfaces/viewport_parameter_listener.mojom";
interface Gpu {
CreateOnscreenGLES2Context(uint64 native_viewport_id,
diff --git a/mojo/services/html_viewer/html_document.cc b/mojo/services/html_viewer/html_document.cc
index 7688442..37942ab 100644
--- a/mojo/services/html_viewer/html_document.cc
+++ b/mojo/services/html_viewer/html_document.cc
@@ -96,7 +96,7 @@ bool CanNavigateLocally(blink::WebFrame* frame,
} // namespace
HTMLDocument::HTMLDocument(
- mojo::ServiceProviderPtr provider,
+ mojo::InterfaceRequest<mojo::ServiceProvider> services,
URLResponsePtr response,
mojo::Shell* shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread,
@@ -111,7 +111,7 @@ HTMLDocument::HTMLDocument(
web_encrypted_media_client_(nullptr) {
exported_services_.AddService(this);
exported_services_.AddService(&view_manager_client_factory_);
- WeakBindToPipe(&exported_services_, provider.PassMessagePipe());
+ WeakBindToPipe(&exported_services_, services.PassMessagePipe());
Load(response_.Pass());
}
@@ -177,14 +177,14 @@ blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() {
void HTMLDocument::initializeLayerTreeView() {
ServiceProviderPtr surfaces_service_provider;
shell_->ConnectToApplication("mojo:surfaces_service",
- GetProxy(&surfaces_service_provider));
+ GetProxy(&surfaces_service_provider), nullptr);
mojo::SurfacesServicePtr surfaces_service;
ConnectToService(surfaces_service_provider.get(), &surfaces_service);
ServiceProviderPtr gpu_service_provider;
// TODO(jamesr): Should be mojo:gpu_service
shell_->ConnectToApplication("mojo:native_viewport_service",
- GetProxy(&gpu_service_provider));
+ GetProxy(&gpu_service_provider), nullptr);
mojo::GpuPtr gpu_service;
ConnectToService(gpu_service_provider.get(), &gpu_service);
web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl(
diff --git a/mojo/services/html_viewer/html_document.h b/mojo/services/html_viewer/html_document.h
index d536157..041967b 100644
--- a/mojo/services/html_viewer/html_document.h
+++ b/mojo/services/html_viewer/html_document.h
@@ -52,13 +52,13 @@ class HTMLDocument : public blink::WebViewClient,
public:
// Load a new HTMLDocument with |response|.
//
- // |service_provider_request| should be used to implement a
- // ServiceProvider which exposes services to the connecting application.
+ // |services| should be used to implement a ServiceProvider which exposes
+ // services to the connecting application.
// Commonly, the connecting application is the ViewManager and it will
// request ViewManagerClient.
//
// |shell| is the Shell connection for this mojo::Application.
- HTMLDocument(mojo::ServiceProviderPtr provider,
+ HTMLDocument(mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::URLResponsePtr response,
mojo::Shell* shell,
scoped_refptr<base::MessageLoopProxy> compositor_thread,
diff --git a/mojo/services/html_viewer/html_viewer.cc b/mojo/services/html_viewer/html_viewer.cc
index e8236b5..e3ea54c 100644
--- a/mojo/services/html_viewer/html_viewer.cc
+++ b/mojo/services/html_viewer/html_viewer.cc
@@ -34,6 +34,8 @@
using mojo::ApplicationConnection;
using mojo::Array;
using mojo::ContentHandler;
+using mojo::InterfaceRequest;
+using mojo::ServiceProvider;
using mojo::ServiceProviderPtr;
using mojo::ShellPtr;
using mojo::String;
@@ -68,16 +70,17 @@ class HTMLViewerApplication : public mojo::Application {
shell_.set_client(this);
ServiceProviderPtr service_provider;
shell_->ConnectToApplication("mojo:network_service",
- GetProxy(&service_provider));
+ GetProxy(&service_provider), nullptr);
ConnectToService(service_provider.get(), &network_service_);
}
void Initialize(Array<String> args) override {}
void AcceptConnection(const String& requestor_url,
- ServiceProviderPtr provider) override {
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) override {
if (initial_response_) {
- OnResponseReceived(URLLoaderPtr(), provider.Pass(),
+ OnResponseReceived(URLLoaderPtr(), services.Pass(),
initial_response_.Pass());
} else {
URLLoaderPtr loader;
@@ -94,15 +97,15 @@ class HTMLViewerApplication : public mojo::Application {
request.Pass(),
base::Bind(&HTMLViewerApplication::OnResponseReceived,
base::Unretained(this), base::Passed(&loader),
- base::Passed(&provider)));
+ base::Passed(&services)));
}
}
private:
void OnResponseReceived(URLLoaderPtr loader,
- ServiceProviderPtr provider,
+ InterfaceRequest<ServiceProvider> services,
URLResponsePtr response) {
- new HTMLDocument(provider.Pass(), response.Pass(), shell_.get(),
+ new HTMLDocument(services.Pass(), response.Pass(), shell_.get(),
compositor_thread_, web_media_player_factory_);
}
diff --git a/mojo/services/html_viewer/webmediaplayer_factory.cc b/mojo/services/html_viewer/webmediaplayer_factory.cc
index f6e5a51..df113bf 100644
--- a/mojo/services/html_viewer/webmediaplayer_factory.cc
+++ b/mojo/services/html_viewer/webmediaplayer_factory.cc
@@ -88,8 +88,8 @@ blink::WebMediaPlayer* WebMediaPlayerFactory::CreateMediaPlayer(
if (enable_mojo_media_renderer_) {
ServiceProviderPtr media_renderer_service_provider;
- shell->ConnectToApplication("mojo:media",
- GetProxy(&media_renderer_service_provider));
+ shell->ConnectToApplication(
+ "mojo:media", GetProxy(&media_renderer_service_provider), nullptr);
media_renderer_factory.reset(new media::MojoRendererFactory(make_scoped_ptr(
new RendererServiceProvider(media_renderer_service_provider.Pass()))));
} else {
diff --git a/mojo/services/input_events/public/interfaces/BUILD.gn b/mojo/services/input_events/public/interfaces/BUILD.gn
index 58ba619..e7a75f2 100644
--- a/mojo/services/input_events/public/interfaces/BUILD.gn
+++ b/mojo/services/input_events/public/interfaces/BUILD.gn
@@ -12,7 +12,9 @@ mojom("interfaces") {
"input_key_codes.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
deps = [
- "//mojo/services/geometry/public/interfaces",
+ "../../../geometry/public/interfaces",
]
}
diff --git a/mojo/services/input_events/public/interfaces/input_events.mojom b/mojo/services/input_events/public/interfaces/input_events.mojom
index 08463bc..4e7dbb5 100644
--- a/mojo/services/input_events/public/interfaces/input_events.mojom
+++ b/mojo/services/input_events/public/interfaces/input_events.mojom
@@ -4,9 +4,9 @@
module mojo;
-import "mojo/services/geometry/public/interfaces/geometry.mojom";
-import "mojo/services/input_events/public/interfaces/input_event_constants.mojom";
-import "mojo/services/input_events/public/interfaces/input_key_codes.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "input_events/public/interfaces/input_event_constants.mojom";
+import "input_events/public/interfaces/input_key_codes.mojom";
struct LocationData {
Point? in_view_location;
diff --git a/mojo/services/native_viewport/public/interfaces/BUILD.gn b/mojo/services/native_viewport/public/interfaces/BUILD.gn
index 25ac003..0311564 100644
--- a/mojo/services/native_viewport/public/interfaces/BUILD.gn
+++ b/mojo/services/native_viewport/public/interfaces/BUILD.gn
@@ -10,10 +10,12 @@ mojom("interfaces") {
"native_viewport.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
public_deps = [
- "//mojo/services/geometry/public/interfaces",
- "//mojo/services/gpu/public/interfaces",
- "//mojo/services/input_events/public/interfaces",
- "//mojo/services/surfaces/public/interfaces:surface_id",
+ "../../../geometry/public/interfaces",
+ "../../../gpu/public/interfaces",
+ "../../../input_events/public/interfaces",
+ "../../../surfaces/public/interfaces:surface_id",
]
}
diff --git a/mojo/services/native_viewport/public/interfaces/native_viewport.mojom b/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
index 4960051..72d3c9d 100644
--- a/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
+++ b/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
@@ -4,10 +4,10 @@
module mojo;
-import "mojo/services/geometry/public/interfaces/geometry.mojom";
-import "mojo/services/gpu/public/interfaces/command_buffer.mojom";
-import "mojo/services/input_events/public/interfaces/input_events.mojom";
-import "mojo/services/surfaces/public/interfaces/surface_id.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "gpu/public/interfaces/command_buffer.mojom";
+import "input_events/public/interfaces/input_events.mojom";
+import "surfaces/public/interfaces/surface_id.mojom";
struct ViewportMetrics {
Size size;
diff --git a/mojo/services/navigation/public/interfaces/BUILD.gn b/mojo/services/navigation/public/interfaces/BUILD.gn
index 66168e2..9b396e7 100644
--- a/mojo/services/navigation/public/interfaces/BUILD.gn
+++ b/mojo/services/navigation/public/interfaces/BUILD.gn
@@ -10,7 +10,9 @@ mojom("interfaces") {
"navigation.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
deps = [
- "//mojo/services/network/public/interfaces",
+ "../../../network/public/interfaces",
]
}
diff --git a/mojo/services/navigation/public/interfaces/navigation.mojom b/mojo/services/navigation/public/interfaces/navigation.mojom
index 668892d..0d2656a 100644
--- a/mojo/services/navigation/public/interfaces/navigation.mojom
+++ b/mojo/services/navigation/public/interfaces/navigation.mojom
@@ -4,7 +4,7 @@
module mojo;
-import "mojo/services/network/public/interfaces/url_loader.mojom";
+import "network/public/interfaces/url_loader.mojom";
// Expresses a preference for where a navigation will be performed.
enum Target {
diff --git a/mojo/services/network/public/interfaces/BUILD.gn b/mojo/services/network/public/interfaces/BUILD.gn
index 27e1ca3..5195bf8 100644
--- a/mojo/services/network/public/interfaces/BUILD.gn
+++ b/mojo/services/network/public/interfaces/BUILD.gn
@@ -18,4 +18,6 @@ mojom("interfaces") {
"url_loader.mojom",
"web_socket.mojom",
]
+
+ import_dirs = [ get_path_info("../../../", "abspath") ]
}
diff --git a/mojo/services/network/public/interfaces/network_service.mojom b/mojo/services/network/public/interfaces/network_service.mojom
index 5996ffc..062285d 100644
--- a/mojo/services/network/public/interfaces/network_service.mojom
+++ b/mojo/services/network/public/interfaces/network_service.mojom
@@ -4,14 +4,14 @@
module mojo;
-import "mojo/services/network/public/interfaces/cookie_store.mojom";
-import "mojo/services/network/public/interfaces/net_address.mojom";
-import "mojo/services/network/public/interfaces/network_error.mojom";
-import "mojo/services/network/public/interfaces/tcp_bound_socket.mojom";
-import "mojo/services/network/public/interfaces/tcp_connected_socket.mojom";
-import "mojo/services/network/public/interfaces/udp_socket.mojom";
-import "mojo/services/network/public/interfaces/url_loader.mojom";
-import "mojo/services/network/public/interfaces/web_socket.mojom";
+import "network/public/interfaces/cookie_store.mojom";
+import "network/public/interfaces/net_address.mojom";
+import "network/public/interfaces/network_error.mojom";
+import "network/public/interfaces/tcp_bound_socket.mojom";
+import "network/public/interfaces/tcp_connected_socket.mojom";
+import "network/public/interfaces/udp_socket.mojom";
+import "network/public/interfaces/url_loader.mojom";
+import "network/public/interfaces/web_socket.mojom";
// TODO Darin suggfests that this should probably be two classes. One for
// high-level origin-build requests like WebSockets and HTTP, and the other for
diff --git a/mojo/services/network/public/interfaces/tcp_bound_socket.mojom b/mojo/services/network/public/interfaces/tcp_bound_socket.mojom
index af79ad4..c8747d8 100644
--- a/mojo/services/network/public/interfaces/tcp_bound_socket.mojom
+++ b/mojo/services/network/public/interfaces/tcp_bound_socket.mojom
@@ -4,10 +4,10 @@
module mojo;
-import "mojo/services/network/public/interfaces/net_address.mojom";
-import "mojo/services/network/public/interfaces/network_error.mojom";
-import "mojo/services/network/public/interfaces/tcp_connected_socket.mojom";
-import "mojo/services/network/public/interfaces/tcp_server_socket.mojom";
+import "network/public/interfaces/net_address.mojom";
+import "network/public/interfaces/network_error.mojom";
+import "network/public/interfaces/tcp_connected_socket.mojom";
+import "network/public/interfaces/tcp_server_socket.mojom";
// Represents a TCP socket that is bound to a local address and port, but
// is not yet in a listening or connected state.
diff --git a/mojo/services/network/public/interfaces/tcp_server_socket.mojom b/mojo/services/network/public/interfaces/tcp_server_socket.mojom
index c37d95f..9305e1b 100644
--- a/mojo/services/network/public/interfaces/tcp_server_socket.mojom
+++ b/mojo/services/network/public/interfaces/tcp_server_socket.mojom
@@ -4,9 +4,9 @@
module mojo;
-import "mojo/services/network/public/interfaces/net_address.mojom";
-import "mojo/services/network/public/interfaces/network_error.mojom";
-import "mojo/services/network/public/interfaces/tcp_connected_socket.mojom";
+import "network/public/interfaces/net_address.mojom";
+import "network/public/interfaces/network_error.mojom";
+import "network/public/interfaces/tcp_connected_socket.mojom";
// Represents a TCP server socket listening for incoming requests.
interface TCPServerSocket {
diff --git a/mojo/services/network/public/interfaces/udp_socket.mojom b/mojo/services/network/public/interfaces/udp_socket.mojom
index 0d74e28..be67e9d 100644
--- a/mojo/services/network/public/interfaces/udp_socket.mojom
+++ b/mojo/services/network/public/interfaces/udp_socket.mojom
@@ -4,8 +4,8 @@
module mojo;
-import "mojo/services/network/public/interfaces/net_address.mojom";
-import "mojo/services/network/public/interfaces/network_error.mojom";
+import "network/public/interfaces/net_address.mojom";
+import "network/public/interfaces/network_error.mojom";
// UDPSocket and UDPSocketClient represent a UDP socket and its client. The
// typical flow of using the interfaces is:
diff --git a/mojo/services/network/public/interfaces/url_loader.mojom b/mojo/services/network/public/interfaces/url_loader.mojom
index 173617b..10f0af3 100644
--- a/mojo/services/network/public/interfaces/url_loader.mojom
+++ b/mojo/services/network/public/interfaces/url_loader.mojom
@@ -4,7 +4,7 @@
module mojo;
-import "mojo/services/network/public/interfaces/network_error.mojom";
+import "network/public/interfaces/network_error.mojom";
struct URLRequest {
// The URL to load.
diff --git a/mojo/services/network/public/interfaces/web_socket.mojom b/mojo/services/network/public/interfaces/web_socket.mojom
index ee64aac..f212724 100644
--- a/mojo/services/network/public/interfaces/web_socket.mojom
+++ b/mojo/services/network/public/interfaces/web_socket.mojom
@@ -4,7 +4,7 @@
module mojo;
-import "mojo/services/network/public/interfaces/network_error.mojom";
+import "network/public/interfaces/network_error.mojom";
interface WebSocket {
enum MessageType {
diff --git a/mojo/services/public/js/application.js b/mojo/services/public/js/application.js
index 77ec17f..a50f84c 100644
--- a/mojo/services/public/js/application.js
+++ b/mojo/services/public/js/application.js
@@ -15,6 +15,7 @@ define("mojo/services/public/js/application", [
constructor(shellHandle, url) {
this.url = url;
this.serviceProviders = [];
+ this.exposedServiceProviders = [];
this.shellHandle_ = shellHandle;
this.shell = new Shell(shellHandle, {
initialize: this.initialize.bind(this),
@@ -25,13 +26,18 @@ define("mojo/services/public/js/application", [
initialize(args) {
}
- doAcceptConnection(url, serviceProviderProxy) {
- var serviceProvider = new ServiceProvider(serviceProviderProxy);
+ doAcceptConnection(url, serviceProviderProxy, exposedServiceProviderProxy) {
+ var serviceProvider = new ServiceProvider(serviceProviderProxy);
this.serviceProviders.push(serviceProvider);
- this.acceptConnection(url, serviceProvider);
+
+ var exposedServiceProvider =
+ new ServiceProvider(exposedServiceProviderProxy);
+ this.exposedServiceProviders.push(exposedServiceProvider);
+
+ this.acceptConnection(url, serviceProvider, exposedServiceProvider);
}
- acceptConnection(url, serviceProvider) {
+ acceptConnection(url, serviceProvider, exposedServiceProvider) {
}
quit() {
diff --git a/mojo/services/surfaces/public/interfaces/BUILD.gn b/mojo/services/surfaces/public/interfaces/BUILD.gn
index 323d5af..76f5172 100644
--- a/mojo/services/surfaces/public/interfaces/BUILD.gn
+++ b/mojo/services/surfaces/public/interfaces/BUILD.gn
@@ -12,11 +12,13 @@ mojom("interfaces") {
"surfaces_service.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
deps = [
":surface_id",
- "//mojo/services/geometry/public/interfaces",
- "//mojo/services/gpu/public/interfaces",
- "//mojo/services/native_viewport/public/interfaces",
+ "../../../geometry/public/interfaces",
+ "../../../gpu/public/interfaces",
+ "../../../native_viewport/public/interfaces",
]
}
diff --git a/mojo/services/surfaces/public/interfaces/quads.mojom b/mojo/services/surfaces/public/interfaces/quads.mojom
index 52a667d..58f85e0 100644
--- a/mojo/services/surfaces/public/interfaces/quads.mojom
+++ b/mojo/services/surfaces/public/interfaces/quads.mojom
@@ -4,8 +4,8 @@
module mojo;
-import "mojo/services/geometry/public/interfaces/geometry.mojom";
-import "mojo/services/surfaces/public/interfaces/surface_id.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "surfaces/public/interfaces/surface_id.mojom";
struct Color {
uint32 rgba;
diff --git a/mojo/services/surfaces/public/interfaces/surface_id.mojom b/mojo/services/surfaces/public/interfaces/surface_id.mojom
index d68e2e7..197e6f8b 100644
--- a/mojo/services/surfaces/public/interfaces/surface_id.mojom
+++ b/mojo/services/surfaces/public/interfaces/surface_id.mojom
@@ -8,6 +8,12 @@ module mojo;
// local part is allocated by the client using any scheme that avoids
// duplicates. The namespace is allocated by the service and will be different
// for each client (aka each connection to mojo.Surface).
+//
+// The special id_namespace value 0 is equivalent to the namespace of the
+// client. This can be used to create, destroy and submit frames to
+// surfaces before learning the namespace and to reference other surfaces
+// owned by the same client. The actual id namespace must be used to pass
+// surface ids to other clients for them to reference.
struct SurfaceId {
uint32 local;
uint32 id_namespace;
diff --git a/mojo/services/surfaces/public/interfaces/surfaces.mojom b/mojo/services/surfaces/public/interfaces/surfaces.mojom
index caadded..7badcd3 100644
--- a/mojo/services/surfaces/public/interfaces/surfaces.mojom
+++ b/mojo/services/surfaces/public/interfaces/surfaces.mojom
@@ -4,11 +4,11 @@
module mojo;
-import "mojo/services/geometry/public/interfaces/geometry.mojom";
-import "mojo/services/gpu/public/interfaces/command_buffer.mojom";
-import "mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom";
-import "mojo/services/surfaces/public/interfaces/quads.mojom";
-import "mojo/services/surfaces/public/interfaces/surface_id.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "gpu/public/interfaces/command_buffer.mojom";
+import "gpu/public/interfaces/viewport_parameter_listener.mojom";
+import "surfaces/public/interfaces/quads.mojom";
+import "surfaces/public/interfaces/surface_id.mojom";
enum ResourceFormat {
RGBA_8888,
@@ -61,19 +61,17 @@ interface SurfaceClient {
[Client=SurfaceClient]
interface Surface {
- // The id's local field is allocated by the caller and must be unique. The
- // id_namespace field on the id may be 0 or this connection's namespace.
- CreateSurface(SurfaceId id);
+ CreateSurface(uint32 id_local);
// The client can only submit frames to surfaces created with this
// connection. After the submitted frame is drawn for the first time, the
// surface will respond to the SubmitFrame message. Clients should use this
// acknowledgement to ratelimit frame submissions.
- SubmitFrame(SurfaceId id, Frame frame) => ();
- DestroySurface(SurfaceId id);
+ SubmitFrame(uint32 id_local, Frame frame) => ();
+ DestroySurface(uint32 id_local);
CreateGLES2BoundSurface(CommandBuffer gles2_client,
- SurfaceId id,
+ uint32 id_local,
Size size,
ViewportParameterListener& listener);
};
diff --git a/mojo/services/surfaces/public/interfaces/surfaces_service.mojom b/mojo/services/surfaces/public/interfaces/surfaces_service.mojom
index 5ced108..e1ca690 100644
--- a/mojo/services/surfaces/public/interfaces/surfaces_service.mojom
+++ b/mojo/services/surfaces/public/interfaces/surfaces_service.mojom
@@ -4,10 +4,12 @@
module mojo;
-import "mojo/services/surfaces/public/interfaces/surfaces.mojom";
+import "surfaces/public/interfaces/surfaces.mojom";
// Use this interface to request connections to the surfaces service. Each
// connection is associated with an id namespace
interface SurfacesService {
+ // DEPRECATED: Just connect to mojo.Surface directly and receive the id
+ // namespace via SetIdNamespace.
CreateSurfaceConnection() => (Surface surface, uint32 id_namespace);
};
diff --git a/mojo/services/view_manager/public/cpp/tests/BUILD.gn b/mojo/services/view_manager/public/cpp/tests/BUILD.gn
index fb2ed5a..ec164ac 100644
--- a/mojo/services/view_manager/public/cpp/tests/BUILD.gn
+++ b/mojo/services/view_manager/public/cpp/tests/BUILD.gn
@@ -13,20 +13,16 @@ test("mojo_view_manager_lib_unittests") {
deps = [
"//base",
"//base/test:test_support",
- "//mojo/application_manager",
"//mojo/converters/geometry",
"//mojo/environment:chromium",
"//mojo/public/cpp/application",
"//mojo/services/geometry/public/cpp",
"//mojo/services/geometry/public/interfaces",
"//mojo/services/view_manager/public/cpp",
+ "//mojo/services/view_manager/public/cpp/lib:run_unittests",
"//mojo/services/view_manager/public/interfaces",
+ "//shell/application_manager",
"//shell:test_support",
"//testing/gtest",
]
- if (use_aura) {
- deps += [ "//mojo/services/view_manager/public/cpp/lib:run_unittests" ]
- } else {
- deps += [ "//mojo/edk/test:run_all_unittests" ]
- }
}
diff --git a/mojo/services/view_manager/public/cpp/tests/DEPS b/mojo/services/view_manager/public/cpp/tests/DEPS
index 7f57796..af27b9a 100644
--- a/mojo/services/view_manager/public/cpp/tests/DEPS
+++ b/mojo/services/view_manager/public/cpp/tests/DEPS
@@ -1,5 +1,5 @@
include_rules = [
- "!mojo/application_manager",
+ "!shell/application_manager",
"!shell/shell_test_helper.h",
"+mojo/services/geometry/public",
]
diff --git a/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc b/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
index abdb095..bbfc742 100644
--- a/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
+++ b/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
@@ -7,7 +7,6 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/logging.h"
-#include "mojo/application_manager/application_manager.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
@@ -20,6 +19,7 @@
#include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
#include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
#include "mojo/services/view_manager/public/cpp/view_observer.h"
+#include "shell/application_manager/application_manager.h"
#include "shell/shell_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/mojo/services/view_manager/public/interfaces/BUILD.gn b/mojo/services/view_manager/public/interfaces/BUILD.gn
index 574473e..69a454b 100644
--- a/mojo/services/view_manager/public/interfaces/BUILD.gn
+++ b/mojo/services/view_manager/public/interfaces/BUILD.gn
@@ -12,6 +12,8 @@ mojom("interfaces") {
"view_manager_constants.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
mojo_sdk_deps = [ "mojo/public/interfaces/application" ]
deps = [
diff --git a/mojo/services/view_manager/public/interfaces/animations.mojom b/mojo/services/view_manager/public/interfaces/animations.mojom
index 8b3b617..59572c4 100644
--- a/mojo/services/view_manager/public/interfaces/animations.mojom
+++ b/mojo/services/view_manager/public/interfaces/animations.mojom
@@ -4,7 +4,7 @@
module mojo;
-import "../../../geometry/public/interfaces/geometry.mojom";
+import "geometry/public/interfaces/geometry.mojom";
enum AnimationTweenType {
LINEAR,
diff --git a/mojo/services/view_manager/public/interfaces/view_manager.mojom b/mojo/services/view_manager/public/interfaces/view_manager.mojom
index 05ec857..0f5c51d 100644
--- a/mojo/services/view_manager/public/interfaces/view_manager.mojom
+++ b/mojo/services/view_manager/public/interfaces/view_manager.mojom
@@ -4,12 +4,12 @@
module mojo;
-import "../../../geometry/public/interfaces/geometry.mojom";
-import "../../../input_events/public/interfaces/input_events.mojom";
-import "../../../native_viewport/public/interfaces/native_viewport.mojom";
-import "../../../surfaces/public/interfaces/surface_id.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "input_events/public/interfaces/input_events.mojom";
import "mojo/public/interfaces/application/service_provider.mojom";
-import "view_manager_constants.mojom";
+import "native_viewport/public/interfaces/native_viewport.mojom";
+import "surfaces/public/interfaces/surface_id.mojom";
+import "view_manager/public/interfaces/view_manager_constants.mojom";
struct ViewData {
uint32 parent_id;
diff --git a/mojo/services/window_manager/public/interfaces/BUILD.gn b/mojo/services/window_manager/public/interfaces/BUILD.gn
index 6e166f9..14b7d2c 100644
--- a/mojo/services/window_manager/public/interfaces/BUILD.gn
+++ b/mojo/services/window_manager/public/interfaces/BUILD.gn
@@ -11,10 +11,12 @@ mojom("interfaces") {
"window_manager_internal.mojom",
]
+ import_dirs = [ get_path_info("../../../", "abspath") ]
+
mojo_sdk_deps = [ "mojo/public/interfaces/application" ]
deps = [
- "//mojo/services/geometry/public/interfaces",
- "//mojo/services/input_events/public/interfaces",
+ "../../../geometry/public/interfaces",
+ "../../../input_events/public/interfaces",
]
}
diff --git a/mojo/services/window_manager/public/interfaces/window_manager.mojom b/mojo/services/window_manager/public/interfaces/window_manager.mojom
index b629c8f..a2ef594 100644
--- a/mojo/services/window_manager/public/interfaces/window_manager.mojom
+++ b/mojo/services/window_manager/public/interfaces/window_manager.mojom
@@ -4,8 +4,8 @@
module mojo;
+import "input_events/public/interfaces/input_events.mojom";
import "mojo/public/interfaces/application/service_provider.mojom";
-import "mojo/services/input_events/public/interfaces/input_events.mojom";
[Client=WindowManagerClient]
interface WindowManager {
diff --git a/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom b/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom
index 7892288..6b85632 100644
--- a/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom
+++ b/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom
@@ -4,8 +4,8 @@
module mojo;
-import "mojo/services/geometry/public/interfaces/geometry.mojom";
-import "mojo/services/input_events/public/interfaces/input_events.mojom";
+import "geometry/public/interfaces/geometry.mojom";
+import "input_events/public/interfaces/input_events.mojom";
// WindowManagerInternal is an interface provided by the WindowManager
// exclusively to the ViewManager.