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

Unified Diff: services/icu_data/icu_data_impl.cc

Issue 1987363004: Build libraries for a number of services. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: remove unnecessary imports 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/icu_data/icu_data_impl.h ('k') | services/icu_data/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/icu_data/icu_data_impl.cc
diff --git a/services/icu_data/icu_data_impl.cc b/services/icu_data/icu_data_impl.cc
index c1566f6f6f1ee393843e8190b68776e4307d6b50..48614fe731a8931e330d4e93f19dedd64391df14 100644
--- a/services/icu_data/icu_data_impl.cc
+++ b/services/icu_data/icu_data_impl.cc
@@ -2,69 +2,53 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/common/binding_set.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
+#include "services/icu_data/icu_data_impl.h"
+
#include "mojo/public/cpp/bindings/interface_ptr.h"
-#include "mojo/services/icu_data/interfaces/icu_data.mojom.h"
#include "services/icu_data/kICUData.h"
namespace icu_data {
-class ICUDataImpl : public mojo::ApplicationDelegate, public ICUData {
- public:
- ICUDataImpl() {}
- ~ICUDataImpl() override {}
-
- // mojo::ApplicationDelegate implementation.
- bool ConfigureIncomingConnection(
- mojo::ServiceProviderImpl* service_provider_impl) override {
- service_provider_impl->AddService<ICUData>(
- [this](const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<ICUData> icu_data_request) {
- bindings_.AddBinding(this, icu_data_request.Pass());
- });
+ICUDataImpl::ICUDataImpl() {}
+ICUDataImpl::~ICUDataImpl() {}
- return true;
- }
+bool ICUDataImpl::ConfigureIncomingConnection(
+ mojo::ServiceProviderImpl* service_provider_impl) {
+ service_provider_impl->AddService<ICUData>(
+ [this](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<ICUData> icu_data_request) {
+ bindings_.AddBinding(this, icu_data_request.Pass());
+ });
- void Map(const mojo::String& sha1hash,
- const mojo::Callback<void(mojo::ScopedSharedBufferHandle)>& callback)
- override {
- if (std::string(sha1hash) != std::string(kICUData.hash)) {
- LOG(WARNING) << "Failed to match sha1sum. Expected " << kICUData.hash;
- callback.Run(mojo::ScopedSharedBufferHandle());
- return;
- }
- EnsureBuffer();
- mojo::ScopedSharedBufferHandle handle;
- // FIXME: We should create a read-only duplicate of the handle.
- mojo::DuplicateBuffer(buffer_->handle.get(), nullptr, &handle);
- callback.Run(handle.Pass());
- }
+ return true;
+}
- private:
- void EnsureBuffer() {
- if (buffer_)
- return;
- buffer_.reset(new mojo::SharedBuffer(kICUData.size));
- void* ptr = nullptr;
- MojoResult rv = mojo::MapBuffer(buffer_->handle.get(), 0, kICUData.size,
- &ptr, MOJO_MAP_BUFFER_FLAG_NONE);
- CHECK_EQ(rv, MOJO_RESULT_OK);
- memcpy(ptr, kICUData.data, kICUData.size);
- rv = mojo::UnmapBuffer(ptr);
- CHECK_EQ(rv, MOJO_RESULT_OK);
+void ICUDataImpl::Map(
+ const mojo::String& sha1hash,
+ const mojo::Callback<void(mojo::ScopedSharedBufferHandle)>& callback) {
+ if (std::string(sha1hash) != std::string(kICUData.hash)) {
+ LOG(WARNING) << "Failed to match sha1sum. Expected " << kICUData.hash;
+ callback.Run(mojo::ScopedSharedBufferHandle());
+ return;
}
-
- scoped_ptr<mojo::SharedBuffer> buffer_;
- mojo::BindingSet<ICUData> bindings_;
-};
+ EnsureBuffer();
+ mojo::ScopedSharedBufferHandle handle;
+ // FIXME: We should create a read-only duplicate of the handle.
+ mojo::DuplicateBuffer(buffer_->handle.get(), nullptr, &handle);
+ callback.Run(handle.Pass());
}
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new icu_data::ICUDataImpl);
- return runner.Run(application_request);
+void ICUDataImpl::EnsureBuffer() {
+ if (buffer_)
+ return;
+ buffer_.reset(new mojo::SharedBuffer(kICUData.size));
+ void* ptr = nullptr;
+ MojoResult rv = mojo::MapBuffer(buffer_->handle.get(), 0, kICUData.size, &ptr,
+ MOJO_MAP_BUFFER_FLAG_NONE);
+ CHECK_EQ(rv, MOJO_RESULT_OK);
+ memcpy(ptr, kICUData.data, kICUData.size);
+ rv = mojo::UnmapBuffer(ptr);
+ CHECK_EQ(rv, MOJO_RESULT_OK);
}
+
+} // namespace icu_data
« no previous file with comments | « services/icu_data/icu_data_impl.h ('k') | services/icu_data/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698