| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 const GURL url(kModulePrefix + id); | 93 const GURL url(kModulePrefix + id); |
| 94 // TODO(sky): better error checks here? | 94 // TODO(sky): better error checks here? |
| 95 DCHECK(url.is_valid() && !url.is_empty()); | 95 DCHECK(url.is_valid() && !url.is_empty()); |
| 96 DCHECK(fetched_modules_.find(id) == fetched_modules_.end()); | 96 DCHECK(fetched_modules_.find(id) == fetched_modules_.end()); |
| 97 fetched_modules_.insert(id); | 97 fetched_modules_.insert(id); |
| 98 ResourceFetcher* fetcher = ResourceFetcher::Create(url); | 98 ResourceFetcher* fetcher = ResourceFetcher::Create(url); |
| 99 module_fetchers_.push_back(fetcher); | 99 module_fetchers_.push_back(fetcher); |
| 100 fetcher->Start(frame_, | 100 fetcher->Start(frame_, |
| 101 blink::WebURLRequest::RequestContextScript, | 101 blink::WebURLRequest::RequestContextScript, |
| 102 blink::WebURLRequest::FrameTypeNone, | 102 blink::WebURLRequest::FrameTypeNone, |
| 103 ResourceFetcher::PLATFORM_LOADER, |
| 103 base::Bind(&WebUIMojoContextState::OnFetchModuleComplete, | 104 base::Bind(&WebUIMojoContextState::OnFetchModuleComplete, |
| 104 base::Unretained(this), | 105 base::Unretained(this), |
| 105 fetcher)); | 106 fetcher)); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void WebUIMojoContextState::OnFetchModuleComplete( | 109 void WebUIMojoContextState::OnFetchModuleComplete( |
| 109 ResourceFetcher* fetcher, | 110 ResourceFetcher* fetcher, |
| 110 const blink::WebURLResponse& response, | 111 const blink::WebURLResponse& response, |
| 111 const std::string& data) { | 112 const std::string& data) { |
| 112 DCHECK_EQ(kModulePrefix, | 113 DCHECK_EQ(kModulePrefix, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 131 const std::vector<std::string>& dependencies) { | 132 const std::vector<std::string>& dependencies) { |
| 132 FetchModules(dependencies); | 133 FetchModules(dependencies); |
| 133 | 134 |
| 134 gin::ContextHolder* context_holder = runner_->GetContextHolder(); | 135 gin::ContextHolder* context_holder = runner_->GetContextHolder(); |
| 135 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( | 136 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( |
| 136 context_holder->context()); | 137 context_holder->context()); |
| 137 registry->AttemptToLoadMoreModules(context_holder->isolate()); | 138 registry->AttemptToLoadMoreModules(context_holder->isolate()); |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace content | 141 } // namespace content |
| OLD | NEW |