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

Side by Side Diff: gin/modules/file_module_provider.h

Issue 401723002: Mojo: Log an error when we fail to find a JS module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gin/modules/file_module_provider.cc » ('j') | gin/modules/file_module_provider.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef GIN_MODULES_FILE_MODULE_PROVIDER_H_ 5 #ifndef GIN_MODULES_FILE_MODULE_PROVIDER_H_
6 #define GIN_MODULES_FILE_MODULE_PROVIDER_H_ 6 #define GIN_MODULES_FILE_MODULE_PROVIDER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/weak_ptr.h"
13 #include "gin/gin_export.h" 15 #include "gin/gin_export.h"
14 #include "gin/runner.h" 16 #include "gin/runner.h"
15 17
16 namespace gin { 18 namespace gin {
17 19
18 // FileModuleProvider knows how to load AMD modules off disk. It searches for 20 // FileModuleProvider knows how to load AMD modules off disk. It searches for
19 // modules in the directories indiciated by |search_paths|. Although we still 21 // modules in the directories indiciated by |search_paths|. Although we still
20 // read from the file system on the main thread, we'll eventually want to move 22 // read from the file system on the main thread, we'll eventually want to move
21 // the reads to a background thread. 23 // the reads to a background thread.
22 class GIN_EXPORT FileModuleProvider { 24 class GIN_EXPORT FileModuleProvider {
23 public: 25 public:
24 explicit FileModuleProvider( 26 explicit FileModuleProvider(
25 const std::vector<base::FilePath>& search_paths); 27 const std::vector<base::FilePath>& search_paths);
26 ~FileModuleProvider(); 28 ~FileModuleProvider();
27 29
28 // Searches for modules with |ids| in the file system. If found, the modules 30 // Searches for modules with |ids| in the file system. If found, the modules
29 // will be executed asynchronously by |runner|. 31 // will be executed asynchronously by |runner|.
30 void AttempToLoadModules(Runner* runner, const std::set<std::string>& ids); 32 void AttemptToLoadModules(Runner* runner, const std::set<std::string>& ids);
33
34 void set_completion_callback(
35 base::Callback<void(const std::set<std::string>&)> callback) {
36 completion_callback_ = callback;
37 }
38 void reset_completion_callback() {
39 completion_callback_.Reset();
40 }
31 41
32 private: 42 private:
43 void OnReadCompleted(const std::string& id, bool success);
44
45 base::WeakPtrFactory<FileModuleProvider> weak_factory_;
46
33 std::vector<base::FilePath> search_paths_; 47 std::vector<base::FilePath> search_paths_;
34 48
35 // We'll only search for a given module once. We remember the set of modules 49 // We'll only search for a given module once. We remember the set of modules
36 // we've already looked for in |attempted_ids_|. 50 // we've already looked for in |attempted_ids_|.
37 std::set<std::string> attempted_ids_; 51 std::set<std::string> attempted_ids_;
38 52
53 // The set of modules that have succeeded or failed to load.
54 std::set<std::string> successful_ids_;
55 std::set<std::string> failed_ids_;
56
57 base::Callback<void(const std::set<std::string>&)> completion_callback_;
58
39 DISALLOW_COPY_AND_ASSIGN(FileModuleProvider); 59 DISALLOW_COPY_AND_ASSIGN(FileModuleProvider);
40 }; 60 };
41 61
42 } // namespace gin 62 } // namespace gin
43 63
44 #endif // GIN_MODULES_FILE_MODULE_PROVIDER_H_ 64 #endif // GIN_MODULES_FILE_MODULE_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | gin/modules/file_module_provider.cc » ('j') | gin/modules/file_module_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698