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

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

Issue 1455833005: Convert ConnectToApplication to take a params class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 1 month 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
« no previous file with comments | « components/mus/ws/window_tree_apptest.cc ('k') | components/web_view/frame_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/application_impl.h"
10 #include "mojo/application/public/cpp/connect.h" 10 #include "mojo/application/public/cpp/connect.h"
11 #include "mojo/application/public/interfaces/service_provider.mojom.h" 11 #include "mojo/application/public/interfaces/service_provider.mojom.h"
12 #include "mojo/application/public/interfaces/shell.mojom.h" 12 #include "mojo/application/public/interfaces/shell.mojom.h"
13 #include "mojo/common/common_type_converters.h" 13 #include "mojo/common/common_type_converters.h"
14 #include "mojo/platform_handle/platform_handle_functions.h" 14 #include "mojo/platform_handle/platform_handle_functions.h"
15 15
16 namespace resource_provider { 16 namespace resource_provider {
17 namespace { 17 namespace {
18 base::File GetFileFromHandle(mojo::ScopedHandle handle) { 18 base::File GetFileFromHandle(mojo::ScopedHandle handle) {
19 CHECK(handle.is_valid()); 19 CHECK(handle.is_valid());
20 MojoPlatformHandle platform_handle; 20 MojoPlatformHandle platform_handle;
21 CHECK(MojoExtractPlatformHandle(handle.release().value(), 21 CHECK(MojoExtractPlatformHandle(handle.release().value(),
22 &platform_handle) == MOJO_RESULT_OK); 22 &platform_handle) == MOJO_RESULT_OK);
23 return base::File(platform_handle).Pass(); 23 return base::File(platform_handle).Pass();
24 } 24 }
25 } 25 }
26 26
27 ResourceLoader::ResourceLoader(mojo::ApplicationImpl* app, 27 ResourceLoader::ResourceLoader(mojo::ApplicationImpl* app,
28 const std::set<std::string>& paths) 28 const std::set<std::string>& paths)
29 : loaded_(false), did_block_(false) { 29 : loaded_(false), did_block_(false) {
30 mojo::URLRequestPtr request(mojo::URLRequest::New()); 30 app->ConnectToService("mojo:resource_provider", &resource_provider_);
31 request->url = mojo::String::From("mojo:resource_provider");
32 app->ConnectToService(request.Pass(), &resource_provider_);
33 std::vector<std::string> paths_vector(paths.begin(), paths.end()); 31 std::vector<std::string> paths_vector(paths.begin(), paths.end());
34 resource_provider_->GetResources( 32 resource_provider_->GetResources(
35 mojo::Array<mojo::String>::From(paths_vector), 33 mojo::Array<mojo::String>::From(paths_vector),
36 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this), 34 base::Bind(&ResourceLoader::OnGotResources, base::Unretained(this),
37 paths_vector)); 35 paths_vector));
38 } 36 }
39 37
40 ResourceLoader::~ResourceLoader() { 38 ResourceLoader::~ResourceLoader() {
41 } 39 }
42 40
(...skipping 19 matching lines...) Expand all
62 CHECK(!resources.is_null()); 60 CHECK(!resources.is_null());
63 CHECK_EQ(resources.size(), paths.size()); 61 CHECK_EQ(resources.size(), paths.size());
64 for (size_t i = 0; i < resources.size(); ++i) { 62 for (size_t i = 0; i < resources.size(); ++i) {
65 resource_map_[paths[i]].reset( 63 resource_map_[paths[i]].reset(
66 new base::File(GetFileFromHandle(resources[i].Pass()))); 64 new base::File(GetFileFromHandle(resources[i].Pass())));
67 } 65 }
68 loaded_ = true; 66 loaded_ = true;
69 } 67 }
70 68
71 } // namespace resource_provider 69 } // namespace resource_provider
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree_apptest.cc ('k') | components/web_view/frame_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698