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

Side by Side Diff: services/icu_data/icu_data_impl.cc

Issue 1981513002: ApplicationConnection devolution, part 2.2. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « services/http_server/http_server_app.cc ('k') | services/keyboard/linux/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/application/application_runner_chromium.h" 5 #include "mojo/application/application_runner_chromium.h"
6 #include "mojo/common/binding_set.h" 6 #include "mojo/common/binding_set.h"
7 #include "mojo/public/c/system/main.h" 7 #include "mojo/public/c/system/main.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/interface_factory.h"
11 #include "mojo/public/cpp/bindings/interface_ptr.h" 10 #include "mojo/public/cpp/bindings/interface_ptr.h"
12 #include "mojo/services/icu_data/interfaces/icu_data.mojom.h" 11 #include "mojo/services/icu_data/interfaces/icu_data.mojom.h"
13 #include "services/icu_data/kICUData.h" 12 #include "services/icu_data/kICUData.h"
14 13
15 namespace icu_data { 14 namespace icu_data {
16 15
17 class ICUDataImpl : public mojo::ApplicationDelegate, 16 class ICUDataImpl : public mojo::ApplicationDelegate, public ICUData {
18 public ICUData,
19 public mojo::InterfaceFactory<ICUData> {
20 public: 17 public:
21 ICUDataImpl() {} 18 ICUDataImpl() {}
22 ~ICUDataImpl() override {} 19 ~ICUDataImpl() override {}
23 20
24 // mojo::ApplicationDelegate implementation. 21 // mojo::ApplicationDelegate implementation.
25 bool ConfigureIncomingConnection( 22 bool ConfigureIncomingConnection(
26 mojo::ApplicationConnection* connection) override { 23 mojo::ApplicationConnection* connection) override {
27 connection->AddService(this); 24 connection->GetServiceProviderImpl().AddService<ICUData>(
25 [this](const mojo::ConnectionContext& connection_context,
26 mojo::InterfaceRequest<ICUData> icu_data_request) {
27 bindings_.AddBinding(this, icu_data_request.Pass());
28 });
29
28 return true; 30 return true;
29 } 31 }
30 32
31 // mojo::InterfaceFactory<mojo::ICUData> implementation.
32 void Create(const mojo::ConnectionContext& connection,
33 mojo::InterfaceRequest<ICUData> request) override {
34 bindings_.AddBinding(this, request.Pass());
35 }
36
37 void Map(const mojo::String& sha1hash, 33 void Map(const mojo::String& sha1hash,
38 const mojo::Callback<void(mojo::ScopedSharedBufferHandle)>& callback) 34 const mojo::Callback<void(mojo::ScopedSharedBufferHandle)>& callback)
39 override { 35 override {
40 if (std::string(sha1hash) != std::string(kICUData.hash)) { 36 if (std::string(sha1hash) != std::string(kICUData.hash)) {
41 LOG(WARNING) << "Failed to match sha1sum. Expected " << kICUData.hash; 37 LOG(WARNING) << "Failed to match sha1sum. Expected " << kICUData.hash;
42 callback.Run(mojo::ScopedSharedBufferHandle()); 38 callback.Run(mojo::ScopedSharedBufferHandle());
43 return; 39 return;
44 } 40 }
45 EnsureBuffer(); 41 EnsureBuffer();
46 mojo::ScopedSharedBufferHandle handle; 42 mojo::ScopedSharedBufferHandle handle;
(...skipping 18 matching lines...) Expand all
65 61
66 scoped_ptr<mojo::SharedBuffer> buffer_; 62 scoped_ptr<mojo::SharedBuffer> buffer_;
67 mojo::BindingSet<ICUData> bindings_; 63 mojo::BindingSet<ICUData> bindings_;
68 }; 64 };
69 } 65 }
70 66
71 MojoResult MojoMain(MojoHandle application_request) { 67 MojoResult MojoMain(MojoHandle application_request) {
72 mojo::ApplicationRunnerChromium runner(new icu_data::ICUDataImpl); 68 mojo::ApplicationRunnerChromium runner(new icu_data::ICUDataImpl);
73 return runner.Run(application_request); 69 return runner.Run(application_request);
74 } 70 }
OLDNEW
« no previous file with comments | « services/http_server/http_server_app.cc ('k') | services/keyboard/linux/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698