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

Unified Diff: components/resource_provider/resource_provider_app.cc

Issue 1108403008: Adds resource_provider::ResourceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
Index: components/resource_provider/resource_provider_app.cc
diff --git a/components/resource_provider/resource_provider_app.cc b/components/resource_provider/resource_provider_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..17a6b9698a5c8f3ebb0ce934c45c771cd3fcd6ba
--- /dev/null
+++ b/components/resource_provider/resource_provider_app.cc
@@ -0,0 +1,54 @@
+// Copyright 2015 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 "components/resource_provider/resource_provider_app.h"
+
+#include "components/resource_provider/file_utils.h"
+#include "components/resource_provider/resource_provider_impl.h"
+#include "third_party/mojo/src/mojo/public/cpp/application/application_connection.h"
+#include "url/gurl.h"
+
+namespace resource_provider {
+namespace {
+
+base::SequencedWorkerPool* GetBlockingPool() {
+ base::SequencedWorkerPool* pool = nullptr;
+ if (!pool)
+ pool = new base::SequencedWorkerPool(3, "resource_provider");
+ return pool;
+}
+
+} // namespace
+
+ResourceProviderApp::ResourceProviderApp() {
+}
+
+ResourceProviderApp::~ResourceProviderApp() {
+}
+
+void ResourceProviderApp::Initialize(mojo::ApplicationImpl* app) {
+}
+
+bool ResourceProviderApp::ConfigureIncomingConnection(
+ mojo::ApplicationConnection* connection) {
+ const base::FilePath app_path(
+ GetPathForApplicationUrl(GURL(connection->GetRemoteApplicationURL())));
+ if (app_path.empty())
+ return false; // The specified app has no resources.
+
+ connection->AddService<ResourceProvider>(this);
+ return true;
+}
+
+void ResourceProviderApp::Create(
+ mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<ResourceProvider> request) {
+ const base::FilePath app_path(
+ GetPathForApplicationUrl(GURL(connection->GetRemoteApplicationURL())));
+ CHECK(!app_path.empty());
+ bindings_.AddBinding(new ResourceProviderImpl(app_path, GetBlockingPool()),
+ request.Pass());
+}
+
+} // namespace resource_provider

Powered by Google App Engine
This is Rietveld 408576698