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

Unified Diff: mojo/shell/sample_app.cc

Issue 47433002: Cleanup mojo_shell and sample_app a bit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/run.cc ('k') | mojo/shell/url_request_context_getter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/sample_app.cc
diff --git a/mojo/shell/sample_app.cc b/mojo/shell/sample_app.cc
deleted file mode 100644
index 820bdd4d95fbdca8fe666eb538ad1e16bd1e506c..0000000000000000000000000000000000000000
--- a/mojo/shell/sample_app.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2013 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.
-
-#include <stdio.h>
-
-#include "base/basictypes.h"
-#include "mojo/public/system/core.h"
-#include "mojo/system/core_impl.h"
-
-#if defined(OS_WIN)
-#if !defined(CDECL)
-#define CDECL __cdecl
-#endif
-#define SAMPLE_APP_EXPORT __declspec(dllexport)
-#else
-#define CDECL
-#define SAMPLE_APP_EXPORT __attribute__((visibility("default")))
-#endif
-
-char* ReadStringFromPipe(mojo::Handle pipe) {
- uint32_t len = 0;
- char* buf = NULL;
- MojoResult result = mojo::ReadMessage(pipe, buf, &len, NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE);
- if (result == MOJO_RESULT_RESOURCE_EXHAUSTED) {
- buf = new char[len];
- result = mojo::ReadMessage(pipe, buf, &len, NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_NONE);
- }
- if (result < MOJO_RESULT_OK) {
- // Failure..
- if (buf)
- delete[] buf;
- return NULL;
- }
- return buf;
-}
-
-class SampleMessageWaiter {
- public:
- explicit SampleMessageWaiter(mojo::Handle pipe) : pipe_(pipe) {}
- ~SampleMessageWaiter() {}
-
- void Read() {
- char* string = ReadStringFromPipe(pipe_);
- if (string) {
- printf("Read string from pipe: %s\n", string);
- delete[] string;
- string = NULL;
- }
- }
-
- void WaitAndRead() {
- MojoResult result = mojo::Wait(pipe_, MOJO_WAIT_FLAG_READABLE, 100);
- if (result < MOJO_RESULT_OK) {
- // Failure...
- }
-
- Read();
- }
-
- private:
-
- mojo::Handle pipe_;
- DISALLOW_COPY_AND_ASSIGN(SampleMessageWaiter);
-};
-
-extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain(
- mojo::Handle pipe) {
- SampleMessageWaiter(pipe).WaitAndRead();
- return MOJO_RESULT_OK;
-}
« no previous file with comments | « mojo/shell/run.cc ('k') | mojo/shell/url_request_context_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698