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

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

Issue 1848423002: Convert //gin to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « gin/isolate_holder.cc ('k') | gin/modules/module_registry.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 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_MODULE_REGISTRY_H_ 5 #ifndef GIN_MODULES_MODULE_REGISTRY_H_
6 #define GIN_MODULES_MODULE_REGISTRY_H_ 6 #define GIN_MODULES_MODULE_REGISTRY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <memory>
10 #include <set> 11 #include <set>
11 #include <string> 12 #include <string>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "gin/gin_export.h" 19 #include "gin/gin_export.h"
20 #include "v8/include/v8.h" 20 #include "v8/include/v8.h"
21 21
22 namespace gin { 22 namespace gin {
23 23
24 class ModuleRegistryObserver; 24 class ModuleRegistryObserver;
25 struct PendingModule; 25 struct PendingModule;
26 26
(...skipping 25 matching lines...) Expand all
52 52
53 void AddObserver(ModuleRegistryObserver* observer); 53 void AddObserver(ModuleRegistryObserver* observer);
54 void RemoveObserver(ModuleRegistryObserver* observer); 54 void RemoveObserver(ModuleRegistryObserver* observer);
55 55
56 // The caller must have already entered our context. 56 // The caller must have already entered our context.
57 void AddBuiltinModule(v8::Isolate* isolate, const std::string& id, 57 void AddBuiltinModule(v8::Isolate* isolate, const std::string& id,
58 v8::Local<v8::Value> module); 58 v8::Local<v8::Value> module);
59 59
60 // The caller must have already entered our context. 60 // The caller must have already entered our context.
61 void AddPendingModule(v8::Isolate* isolate, 61 void AddPendingModule(v8::Isolate* isolate,
62 scoped_ptr<PendingModule> pending); 62 std::unique_ptr<PendingModule> pending);
63 63
64 void LoadModule(v8::Isolate* isolate, 64 void LoadModule(v8::Isolate* isolate,
65 const std::string& id, 65 const std::string& id,
66 LoadModuleCallback callback); 66 LoadModuleCallback callback);
67 67
68 // The caller must have already entered our context. 68 // The caller must have already entered our context.
69 void AttemptToLoadMoreModules(v8::Isolate* isolate); 69 void AttemptToLoadMoreModules(v8::Isolate* isolate);
70 70
71 const std::set<std::string>& available_modules() const { 71 const std::set<std::string>& available_modules() const {
72 return available_modules_; 72 return available_modules_;
73 } 73 }
74 74
75 const std::set<std::string>& unsatisfied_dependencies() const { 75 const std::set<std::string>& unsatisfied_dependencies() const {
76 return unsatisfied_dependencies_; 76 return unsatisfied_dependencies_;
77 } 77 }
78 78
79 private: 79 private:
80 typedef ScopedVector<PendingModule> PendingModuleVector; 80 typedef ScopedVector<PendingModule> PendingModuleVector;
81 typedef std::multimap<std::string, LoadModuleCallback> LoadModuleCallbackMap; 81 typedef std::multimap<std::string, LoadModuleCallback> LoadModuleCallbackMap;
82 82
83 explicit ModuleRegistry(v8::Isolate* isolate); 83 explicit ModuleRegistry(v8::Isolate* isolate);
84 84
85 bool Load(v8::Isolate* isolate, scoped_ptr<PendingModule> pending); 85 bool Load(v8::Isolate* isolate, std::unique_ptr<PendingModule> pending);
86 bool RegisterModule(v8::Isolate* isolate, 86 bool RegisterModule(v8::Isolate* isolate,
87 const std::string& id, 87 const std::string& id,
88 v8::Local<v8::Value> module); 88 v8::Local<v8::Value> module);
89 89
90 bool CheckDependencies(PendingModule* pending); 90 bool CheckDependencies(PendingModule* pending);
91 bool AttemptToLoad(v8::Isolate* isolate, scoped_ptr<PendingModule> pending); 91 bool AttemptToLoad(v8::Isolate* isolate,
92 std::unique_ptr<PendingModule> pending);
92 93
93 v8::Local<v8::Value> GetModule(v8::Isolate* isolate, const std::string& id); 94 v8::Local<v8::Value> GetModule(v8::Isolate* isolate, const std::string& id);
94 95
95 std::set<std::string> available_modules_; 96 std::set<std::string> available_modules_;
96 std::set<std::string> unsatisfied_dependencies_; 97 std::set<std::string> unsatisfied_dependencies_;
97 98
98 LoadModuleCallbackMap waiting_callbacks_; 99 LoadModuleCallbackMap waiting_callbacks_;
99 100
100 PendingModuleVector pending_modules_; 101 PendingModuleVector pending_modules_;
101 v8::Persistent<v8::Object> modules_; 102 v8::Persistent<v8::Object> modules_;
102 103
103 base::ObserverList<ModuleRegistryObserver> observer_list_; 104 base::ObserverList<ModuleRegistryObserver> observer_list_;
104 105
105 DISALLOW_COPY_AND_ASSIGN(ModuleRegistry); 106 DISALLOW_COPY_AND_ASSIGN(ModuleRegistry);
106 }; 107 };
107 108
108 } // namespace gin 109 } // namespace gin
109 110
110 #endif // GIN_MODULES_MODULE_REGISTRY_H_ 111 #endif // GIN_MODULES_MODULE_REGISTRY_H_
OLDNEW
« no previous file with comments | « gin/isolate_holder.cc ('k') | gin/modules/module_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698