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

Unified Diff: mojo/examples/content_handler_demo/content_handler_demo.cc

Issue 684543003: Move //mojo/examples to //examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 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/examples/content_handler_demo/BUILD.gn ('k') | mojo/examples/echo/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/content_handler_demo/content_handler_demo.cc
diff --git a/mojo/examples/content_handler_demo/content_handler_demo.cc b/mojo/examples/content_handler_demo/content_handler_demo.cc
deleted file mode 100644
index 3abf0f78ff295859fae84d1313636490ffd846d9..0000000000000000000000000000000000000000
--- a/mojo/examples/content_handler_demo/content_handler_demo.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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.
-
-#include <stdio.h>
-
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/interface_factory_impl.h"
-#include "mojo/services/public/interfaces/content_handler/content_handler.mojom.h"
-
-namespace mojo {
-namespace examples {
-
-class ContentHandlerApp;
-
-class ContentHandlerImpl : public InterfaceImpl<ContentHandler> {
- public:
- explicit ContentHandlerImpl(ContentHandlerApp* content_handler_app)
- : content_handler_app_(content_handler_app) {
- }
- virtual ~ContentHandlerImpl() {}
-
- private:
- virtual void OnConnect(
- const mojo::String& requestor_url,
- URLResponsePtr response,
- InterfaceRequest<ServiceProvider> service_provider) override;
-
- ContentHandlerApp* content_handler_app_;
-};
-
-class ContentHandlerApp : public ApplicationDelegate {
- public:
- ContentHandlerApp() : content_handler_factory_(this) {
- }
-
- virtual void Initialize(ApplicationImpl* app) override {}
-
- virtual bool ConfigureIncomingConnection(
- ApplicationConnection* connection) override {
- connection->AddService(&content_handler_factory_);
- return true;
- }
-
- void PrintResponse(ScopedDataPipeConsumerHandle body) const {
- for (;;) {
- char buf[512];
- uint32_t num_bytes = sizeof(buf);
- MojoResult result = ReadDataRaw(body.get(), buf, &num_bytes,
- MOJO_READ_DATA_FLAG_NONE);
- if (result == MOJO_RESULT_SHOULD_WAIT) {
- Wait(body.get(),
- MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE);
- } else if (result == MOJO_RESULT_OK) {
- if (fwrite(buf, num_bytes, 1, stdout) != 1) {
- printf("\nUnexpected error writing to file\n");
- break;
- }
- } else {
- break;
- }
-
- printf("\n>>> EOF <<<\n");
- }
- }
-
- private:
- InterfaceFactoryImplWithContext<ContentHandlerImpl,
- ContentHandlerApp> content_handler_factory_;
-};
-
-void ContentHandlerImpl::OnConnect(
- const mojo::String& requestor_url,
- URLResponsePtr response,
- InterfaceRequest<ServiceProvider> service_provider) {
- printf("ContentHandler::OnConnect - requestor_url:%s - body follows\n\n",
- requestor_url.To<std::string>().c_str());
- content_handler_app_->PrintResponse(response->body.Pass());
-}
-
-} // namespace examples
-
-// static
-ApplicationDelegate* ApplicationDelegate::Create() {
- return new examples::ContentHandlerApp();
-}
-
-} // namespace mojo
« no previous file with comments | « mojo/examples/content_handler_demo/BUILD.gn ('k') | mojo/examples/echo/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698