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

Side by Side Diff: content/renderer/web_ui_mojo_context_state.cc

Issue 215373004: Makes mojo WebUI run main only after page finishes loading (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename DidFinishDocumentLoad so it doesn't conflict with RVO Created 6 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/web_ui_mojo.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « content/renderer/web_ui_mojo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698