OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/resource_provider/resource_provider_app.h" |
| 6 |
| 7 #include "components/resource_provider/file_utils.h" |
| 8 #include "components/resource_provider/resource_provider_impl.h" |
| 9 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio
n.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 namespace resource_provider { |
| 13 namespace { |
| 14 |
| 15 base::SequencedWorkerPool* GetBlockingPool() { |
| 16 base::SequencedWorkerPool* pool = nullptr; |
| 17 if (!pool) |
| 18 pool = new base::SequencedWorkerPool(3, "resource_provider"); |
| 19 return pool; |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
| 24 ResourceProviderApp::ResourceProviderApp() { |
| 25 } |
| 26 |
| 27 ResourceProviderApp::~ResourceProviderApp() { |
| 28 } |
| 29 |
| 30 void ResourceProviderApp::Initialize(mojo::ApplicationImpl* app) { |
| 31 } |
| 32 |
| 33 bool ResourceProviderApp::ConfigureIncomingConnection( |
| 34 mojo::ApplicationConnection* connection) { |
| 35 const base::FilePath app_path( |
| 36 GetPathForApplicationUrl(GURL(connection->GetRemoteApplicationURL()))); |
| 37 if (app_path.empty()) |
| 38 return false; // The specified app has no resources. |
| 39 |
| 40 connection->AddService<ResourceProvider>(this); |
| 41 return true; |
| 42 } |
| 43 |
| 44 void ResourceProviderApp::Create( |
| 45 mojo::ApplicationConnection* connection, |
| 46 mojo::InterfaceRequest<ResourceProvider> request) { |
| 47 const base::FilePath app_path( |
| 48 GetPathForApplicationUrl(GURL(connection->GetRemoteApplicationURL()))); |
| 49 CHECK(!app_path.empty()); |
| 50 bindings_.AddBinding(new ResourceProviderImpl(app_path, GetBlockingPool()), |
| 51 request.Pass()); |
| 52 } |
| 53 |
| 54 } // namespace resource_provider |
OLD | NEW |