| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 if (did_block_ || loaded_) | 44 if (did_block_ || loaded_) |
| 45 return loaded_; | 45 return loaded_; |
| 46 | 46 |
| 47 did_block_ = true; | 47 did_block_ = true; |
| 48 resource_provider_.WaitForIncomingResponse(); | 48 resource_provider_.WaitForIncomingResponse(); |
| 49 return loaded_; | 49 return loaded_; |
| 50 } | 50 } |
| 51 | 51 |
| 52 base::File ResourceLoader::ReleaseFile(const std::string& path) { | 52 base::File ResourceLoader::ReleaseFile(const std::string& path) { |
| 53 CHECK(resource_map_.count(path)); | 53 CHECK(resource_map_.count(path)); |
| 54 scoped_ptr<base::File> file_wrapper(std::move(resource_map_[path])); | 54 std::unique_ptr<base::File> file_wrapper(std::move(resource_map_[path])); |
| 55 resource_map_.erase(path); | 55 resource_map_.erase(path); |
| 56 return std::move(*file_wrapper); | 56 return std::move(*file_wrapper); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ResourceLoader::OnGotResources(const std::vector<std::string>& paths, | 59 void ResourceLoader::OnGotResources(const std::vector<std::string>& paths, |
| 60 mojo::Array<mojo::ScopedHandle> resources) { | 60 mojo::Array<mojo::ScopedHandle> resources) { |
| 61 | 61 |
| 62 CHECK(!resources.is_null()); | 62 CHECK(!resources.is_null()); |
| 63 CHECK_EQ(resources.size(), paths.size()); | 63 CHECK_EQ(resources.size(), paths.size()); |
| 64 for (size_t i = 0; i < resources.size(); ++i) { | 64 for (size_t i = 0; i < resources.size(); ++i) { |
| 65 resource_map_[paths[i]].reset( | 65 resource_map_[paths[i]].reset( |
| 66 new base::File(GetFileFromHandle(std::move(resources[i])))); | 66 new base::File(GetFileFromHandle(std::move(resources[i])))); |
| 67 } | 67 } |
| 68 loaded_ = true; | 68 loaded_ = true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace resource_provider | 71 } // namespace resource_provider |
| OLD | NEW |