OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_RENDERER_WEB_UI_MOJO_CONTEXT_STATE_H_ | 5 #ifndef CONTENT_RENDERER_MOJO_CONTEXT_STATE_H_ |
6 #define CONTENT_RENDERER_WEB_UI_MOJO_CONTEXT_STATE_H_ | 6 #define CONTENT_RENDERER_MOJO_CONTEXT_STATE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
13 #include "gin/modules/module_registry_observer.h" | 14 #include "gin/modules/module_registry_observer.h" |
14 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 class WebFrame; | 18 class WebFrame; |
18 class WebURLResponse; | 19 class WebURLResponse; |
19 } | 20 } |
20 | 21 |
21 namespace gin { | 22 namespace gin { |
22 class ContextHolder; | 23 class ContextHolder; |
23 struct PendingModule; | 24 struct PendingModule; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
28 class ResourceFetcher; | 29 class ResourceFetcher; |
29 class WebUIRunner; | 30 class MojoMainRunner; |
30 | 31 |
31 // WebUIMojoContextState manages the modules needed for mojo bindings. It does | 32 // MojoContextState manages the modules needed for mojo bindings. It does this |
32 // this by way of gin. Non-builtin modules are downloaded by way of | 33 // by way of gin. Non-builtin modules are downloaded by way of ResourceFetchers. |
33 // ResourceFetchers. | 34 class MojoContextState : public gin::ModuleRegistryObserver { |
34 class WebUIMojoContextState : public gin::ModuleRegistryObserver { | |
35 public: | 35 public: |
36 WebUIMojoContextState(blink::WebFrame* frame, | 36 MojoContextState(blink::WebFrame* frame, v8::Local<v8::Context> context); |
37 v8::Local<v8::Context> context); | 37 ~MojoContextState() override; |
38 ~WebUIMojoContextState() override; | |
39 | 38 |
40 void Run(); | 39 void Run(); |
41 | 40 |
42 // Returns true if at least one module was added. | 41 // Returns true if at least one module was added. |
43 bool module_added() const { return module_added_; } | 42 bool module_added() const { return module_added_; } |
44 | 43 |
45 private: | 44 private: |
46 class Loader; | 45 class Loader; |
47 | 46 |
48 // Invokes FetchModule() for any modules that have not already been | 47 // Invokes FetchModule() for any modules that have not already been |
(...skipping 13 matching lines...) Expand all Loading... |
62 const std::string& id, | 61 const std::string& id, |
63 const std::vector<std::string>& dependencies) override; | 62 const std::vector<std::string>& dependencies) override; |
64 | 63 |
65 // Frame script is executed in. Also used to download resources. | 64 // Frame script is executed in. Also used to download resources. |
66 blink::WebFrame* frame_; | 65 blink::WebFrame* frame_; |
67 | 66 |
68 // See description above getter. | 67 // See description above getter. |
69 bool module_added_; | 68 bool module_added_; |
70 | 69 |
71 // Executes the script from gin. | 70 // Executes the script from gin. |
72 scoped_ptr<WebUIRunner> runner_; | 71 scoped_ptr<MojoMainRunner> runner_; |
73 | 72 |
74 // Set of fetchers we're waiting on to download script. | 73 // Set of fetchers we're waiting on to download script. |
75 ScopedVector<ResourceFetcher> module_fetchers_; | 74 ScopedVector<ResourceFetcher> module_fetchers_; |
76 | 75 |
77 // Set of modules we've fetched script from. | 76 // Set of modules we've fetched script from. |
78 std::set<std::string> fetched_modules_; | 77 std::set<std::string> fetched_modules_; |
79 | 78 |
80 DISALLOW_COPY_AND_ASSIGN(WebUIMojoContextState); | 79 DISALLOW_COPY_AND_ASSIGN(MojoContextState); |
81 }; | 80 }; |
82 | 81 |
83 } // namespace content | 82 } // namespace content |
84 | 83 |
85 #endif // CONTENT_RENDERER_WEB_UI_MOJO_CONTEXT_STATE_H_ | 84 #endif // CONTENT_RENDERER_MOJO_CONTEXT_STATE_H_ |
OLD | NEW |