1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "base/message_loop/message_loop.h"
9 #include "mojo/common/bindings_support_impl.h"
10 #include "mojo/examples/sample_app/hello_world_client_impl.h"
11 #include "mojo/public/bindings/lib/bindings_support.h"
12 #include "mojo/public/system/core.h"
13 #include "mojo/public/system/macros.h"
19 #define SAMPLE_APP_EXPORT __declspec(dllexport)
22 #define SAMPLE_APP_EXPORT __attribute__((visibility("default")))
28 void SayHello(mojo::Handle pipe
) {
30 HelloWorldClientImpl
client(pipe
);
31 mojo::ScratchBuffer buf
;
32 const std::string
kGreeting("hello, world!");
33 mojo::String
* greeting
= mojo::String::NewCopyOf(&buf
, kGreeting
);
34 client
.service()->Greeting(greeting
);
36 // Run loop to receieve Ack. The client will quit the loop.
37 base::MessageLoop::current()->Run();
43 extern "C" SAMPLE_APP_EXPORT MojoResult CDECL
MojoMain(
45 base::MessageLoop loop
;
46 // Set the global bindings support.
47 mojo::common::BindingsSupportImpl bindings_support
;
48 mojo::BindingsSupport::Set(&bindings_support
);
50 mojo::examples::SayHello(pipe
);
52 mojo::BindingsSupport::Set(NULL
);
53 return MOJO_RESULT_OK
;