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

Side by Side Diff: components/resource_provider/public/cpp/resource_loader.cc

Issue 1407073002: Adds GetDisplays() to WindowManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "components/resource_provider/public/cpp/resource_loader.h" 5 #include "components/resource_provider/public/cpp/resource_loader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "mojo/application/public/cpp/application_impl.h"
9 #include "mojo/application/public/cpp/connect.h" 10 #include "mojo/application/public/cpp/connect.h"
10 #include "mojo/application/public/interfaces/service_provider.mojom.h" 11 #include "mojo/application/public/interfaces/service_provider.mojom.h"
11 #include "mojo/application/public/interfaces/shell.mojom.h" 12 #include "mojo/application/public/interfaces/shell.mojom.h"
12 #include "mojo/common/common_type_converters.h" 13 #include "mojo/common/common_type_converters.h"
13 #include "mojo/platform_handle/platform_handle_functions.h" 14 #include "mojo/platform_handle/platform_handle_functions.h"
14 15
15 namespace resource_provider { 16 namespace resource_provider {
16 namespace { 17 namespace {
17 base::File GetFileFromHandle(mojo::ScopedHandle handle) { 18 base::File GetFileFromHandle(mojo::ScopedHandle handle) {
18 CHECK(handle.is_valid()); 19 CHECK(handle.is_valid());
19 MojoPlatformHandle platform_handle; 20 MojoPlatformHandle platform_handle;
20 CHECK(MojoExtractPlatformHandle(handle.release().value(), 21 CHECK(MojoExtractPlatformHandle(handle.release().value(),
21 &platform_handle) == MOJO_RESULT_OK); 22 &platform_handle) == MOJO_RESULT_OK);
22 return base::File(platform_handle).Pass(); 23 return base::File(platform_handle).Pass();
23 } 24 }
24 } 25 }
25 26
26 ResourceLoader::ResourceLoader(mojo::Shell* shell, 27 ResourceLoader::ResourceLoader(mojo::ApplicationImpl* app,
27 const std::set<std::string>& paths) 28 const std::set<std::string>& paths)
28 : loaded_(false), did_block_(false) { 29 : loaded_(false), did_block_(false) {
29 mojo::URLRequestPtr request(mojo::URLRequest::New()); 30 mojo::URLRequestPtr request(mojo::URLRequest::New());
30 request->url = mojo::String::From("mojo:resource_provider"); 31 request->url = mojo::String::From("mojo:resource_provider");
31 mojo::ServiceProviderPtr resource_provider_service_provider; 32 app->ConnectToService(request.Pass(), &resource_provider_);
32 shell->ConnectToApplication(
33 request.Pass(), GetProxy(&resource_provider_service_provider), nullptr,
34 nullptr, mojo::Shell::ConnectToApplicationCallback());
35 mojo::ConnectToService(resource_provider_service_provider.get(),
36 &resource_provider_);
37 std::vector<std::string> paths_vector(paths.begin(), paths.end()); 33 std::vector<std::string> paths_vector(paths.begin(), paths.end());
38 resource_provider_->GetResources( 34 resource_provider_->GetResources(
39 mojo::Array<mojo::String>::From(paths_vector), 35 mojo::Array<mojo::String>::From(paths_vector),
40 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), 36 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this),
41 paths_vector)); 37 paths_vector));
42 } 38 }
43 39
44 ResourceLoader::~ResourceLoader() { 40 ResourceLoader::~ResourceLoader() {
45 } 41 }
46 42
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 new base::File(GetFileFromHandle(resources[i].Pass()))); 75 new base::File(GetFileFromHandle(resources[i].Pass())));
80 } 76 }
81 loaded_ = true; 77 loaded_ = true;
82 } 78 }
83 79
84 void ResourceLoader::OnGotICU(base::File* file, mojo::ScopedHandle handle) { 80 void ResourceLoader::OnGotICU(base::File* file, mojo::ScopedHandle handle) {
85 *file = GetFileFromHandle(handle.Pass()); 81 *file = GetFileFromHandle(handle.Pass());
86 } 82 }
87 83
88 } // namespace resource_provider 84 } // namespace resource_provider
OLDNEW
« no previous file with comments | « components/resource_provider/public/cpp/resource_loader.h ('k') | components/resource_provider/resource_provider_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698