Build libraries for a number of services.
Build libraries additionally to mojo applications for the following services:
- services/files
- services/icu_data
- services/tracing
- services/ui/input_manager
- services/ui/launcher
R=ppi@chromium.org
Review URL: https://codereview.chromium.org/1987363004 .
diff --git a/services/icu_data/BUILD.gn b/services/icu_data/BUILD.gn
index 094f32c..9e29c2c 100644
--- a/services/icu_data/BUILD.gn
+++ b/services/icu_data/BUILD.gn
@@ -18,6 +18,17 @@
mojo_native_application("icu_data") {
sources = [
+ "main.cc",
+ ]
+
+ deps = [
+ ":lib",
+ "//mojo/application",
+ ]
+}
+
+source_set("lib") {
+ sources = [
"icu_data_impl.cc",
]
diff --git a/services/icu_data/icu_data_impl.cc b/services/icu_data/icu_data_impl.cc
index c1566f6..48614fe 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 {}
+ICUDataImpl::ICUDataImpl() {}
+ICUDataImpl::~ICUDataImpl() {}
- // 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());
- });
+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());
+ });
- return true;
- }
-
- 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());
- }
-
- 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);
- }
-
- scoped_ptr<mojo::SharedBuffer> buffer_;
- mojo::BindingSet<ICUData> bindings_;
-};
+ return true;
}
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new icu_data::ICUDataImpl);
- return runner.Run(application_request);
+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;
+ }
+ 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());
}
+
+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
diff --git a/services/icu_data/icu_data_impl.h b/services/icu_data/icu_data_impl.h
new file mode 100644
index 0000000..6c81120
--- /dev/null
+++ b/services/icu_data/icu_data_impl.h
@@ -0,0 +1,33 @@
+// Copyright 2016 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 "base/memory/scoped_ptr.h"
+#include "mojo/common/binding_set.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/service_provider_impl.h"
+#include "mojo/services/icu_data/interfaces/icu_data.mojom.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;
+
+ void Map(const mojo::String& sha1hash,
+ const mojo::Callback<void(mojo::ScopedSharedBufferHandle)>& callback)
+ override;
+
+ private:
+ void EnsureBuffer();
+
+ scoped_ptr<mojo::SharedBuffer> buffer_;
+ mojo::BindingSet<ICUData> bindings_;
+};
+
+} // namespace icu_data;
diff --git a/services/icu_data/main.cc b/services/icu_data/main.cc
new file mode 100644
index 0000000..a10d795
--- /dev/null
+++ b/services/icu_data/main.cc
@@ -0,0 +1,12 @@
+// Copyright 2016 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 "mojo/application/application_runner_chromium.h"
+#include "mojo/public/c/system/main.h"
+#include "services/icu_data/icu_data_impl.h"
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunnerChromium runner(new icu_data::ICUDataImpl);
+ return runner.Run(application_request);
+}