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 #include "content/renderer/web_ui_mojo_context_state.h" | 5 #include "content/renderer/web_ui_mojo_context_state.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/public/renderer/resource_fetcher.h" | 9 #include "content/public/renderer/resource_fetcher.h" |
10 #include "content/renderer/web_ui_runner.h" | 10 #include "content/renderer/web_ui_runner.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::Unretained(this), fetcher)); | 106 base::Unretained(this), fetcher)); |
107 } | 107 } |
108 | 108 |
109 void WebUIMojoContextState::OnFetchModuleComplete( | 109 void WebUIMojoContextState::OnFetchModuleComplete( |
110 ResourceFetcher* fetcher, | 110 ResourceFetcher* fetcher, |
111 const blink::WebURLResponse& response, | 111 const blink::WebURLResponse& response, |
112 const std::string& data) { | 112 const std::string& data) { |
113 DCHECK_EQ(kModulePrefix, | 113 DCHECK_EQ(kModulePrefix, |
114 response.url().string().utf8().substr(0, arraysize(kModulePrefix) - 1)); | 114 response.url().string().utf8().substr(0, arraysize(kModulePrefix) - 1)); |
115 const std::string module = | 115 const std::string module = |
116 response.url().string().utf8().substr(arraysize(kModulePrefix)); | 116 response.url().string().utf8().substr(arraysize(kModulePrefix) - 1); |
117 // We can't delete fetch right now as the arguments to this function come from | 117 // We can't delete fetch right now as the arguments to this function come from |
118 // it and are used below. Instead use a scope_ptr to cleanup. | 118 // it and are used below. Instead use a scope_ptr to cleanup. |
119 scoped_ptr<ResourceFetcher> deleter(fetcher); | 119 scoped_ptr<ResourceFetcher> deleter(fetcher); |
120 module_fetchers_.weak_erase( | 120 module_fetchers_.weak_erase( |
121 std::find(module_fetchers_.begin(), module_fetchers_.end(), fetcher)); | 121 std::find(module_fetchers_.begin(), module_fetchers_.end(), fetcher)); |
122 if (data.empty()) { | 122 if (data.empty()) { |
123 NOTREACHED(); | 123 NOTREACHED(); |
124 return; // TODO(sky): log something? | 124 return; // TODO(sky): log something? |
125 } | 125 } |
126 | 126 |
127 runner_->Run(data, module); | 127 runner_->Run(data, module); |
128 } | 128 } |
129 | 129 |
130 void WebUIMojoContextState::OnDidAddPendingModule( | 130 void WebUIMojoContextState::OnDidAddPendingModule( |
131 const std::string& id, | 131 const std::string& id, |
132 const std::vector<std::string>& dependencies) { | 132 const std::vector<std::string>& dependencies) { |
133 FetchModules(dependencies); | 133 FetchModules(dependencies); |
134 | 134 |
135 gin::ContextHolder* context_holder = runner_->GetContextHolder(); | 135 gin::ContextHolder* context_holder = runner_->GetContextHolder(); |
136 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( | 136 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( |
137 context_holder->context()); | 137 context_holder->context()); |
138 registry->AttemptToLoadMoreModules(context_holder->isolate()); | 138 registry->AttemptToLoadMoreModules(context_holder->isolate()); |
139 } | 139 } |
140 | 140 |
141 } // namespace content | 141 } // namespace content |
OLD | NEW |