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

Unified Diff: components/resource_provider/public/cpp/resource_loader.h

Issue 1132083003: Makes ResourceLoader own handles and return Files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 5 years, 7 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/public/cpp/resource_loader.h
diff --git a/components/resource_provider/public/cpp/resource_loader.h b/components/resource_provider/public/cpp/resource_loader.h
index d3ef25d3de99073f0cc286f065ccbff9c1b84168..1162180619bd056fc24cfb0b436ccd6775d94289 100644
--- a/components/resource_provider/public/cpp/resource_loader.h
+++ b/components/resource_provider/public/cpp/resource_loader.h
@@ -11,12 +11,17 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "components/resource_provider/public/interfaces/resource_provider.mojom.h"
#include "mojo/platform_handle/platform_handle.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
#include "third_party/mojo/src/mojo/public/cpp/system/handle.h"
#include "third_party/mojo/src/mojo/public/interfaces/application/service_provider.mojom.h"
+namespace base {
+class File;
+}
+
namespace mojo {
class Shell;
}
@@ -29,21 +34,23 @@ namespace resource_provider {
// have been obtained.
class ResourceLoader {
public:
- using ResourceMap = std::map<std::string, MojoPlatformHandle>;
-
ResourceLoader(mojo::Shell* shell, const std::set<std::string>& paths);
~ResourceLoader();
// Uses WaitForIncomingMessage() to block until the results are available, or
// an error occurs. Returns true if the resources were obtained, false on
- // error.
+ // error. This immediately returns if the resources have already been
+ // obtained.
bool BlockUntilLoaded();
- const ResourceMap& resource_map() const { return resource_map_; }
+ // Releases and returns the file wrapping the handle.
+ base::File ReleaseFile(const std::string& path);
bool loaded() const { return loaded_; }
private:
+ using ResourceMap = std::map<std::string, scoped_ptr<base::File>>;
+
// Callback when resources have loaded.
void OnGotResources(const std::vector<std::string>& paths,
mojo::Array<mojo::ScopedHandle> resources);
@@ -55,6 +62,7 @@ class ResourceLoader {
ResourceMap resource_map_;
bool loaded_;
+ bool did_block_;
DISALLOW_COPY_AND_ASSIGN(ResourceLoader);
};
« no previous file with comments | « components/html_viewer/html_viewer_resources.grd ('k') | components/resource_provider/public/cpp/resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698