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

Unified Diff: content/browser/webui/url_data_manager_backend.cc

Issue 1985983002: WebUI: shuffle less between threads when responding to requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: zombie code Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webui/url_data_manager_backend.cc
diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc
index ff5d602d4225626ca13b2b0a8f099e6024688e2c..30721555a8a707ffb845c97d3f024a77e9d96b3a 100644
--- a/content/browser/webui/url_data_manager_backend.cc
+++ b/content/browser/webui/url_data_manager_backend.cc
@@ -57,7 +57,6 @@ const char kChromeURLContentSecurityPolicyHeaderBase[] =
const char kChromeURLXFrameOptionsHeader[] = "X-Frame-Options: DENY";
static const char kNetworkErrorKey[] = "netError";
-const int kNoRenderProcessId = -1;
bool SchemeIsInSchemes(const std::string& scheme,
const std::vector<std::string>& schemes) {
@@ -267,16 +266,34 @@ void URLRequestChromeJob::Start() {
int render_process_id, unused;
bool is_renderer_request = ResourceRequestInfo::GetRenderFrameForRequest(
request_, &render_process_id, &unused);
- if (!is_renderer_request)
- render_process_id = kNoRenderProcessId;
+
+ if (!is_renderer_request) {
+ StartAsync(true);
+ return;
+ }
+
+ const GURL url = request_->url();
+
+ if (url.SchemeIs(kChromeUIScheme)) {
+ std::vector<std::string> hosts;
+ hosts.push_back(content::kChromeUIResourcesHost);
Dan Beam 2016/05/19 03:57:43 fixes this issue: https://codereview.chromium.org/
+ GetContentClient()->
+ browser()->GetAdditionalWebUIHostsToIgnoreParititionCheck(&hosts);
+ if (std::find(hosts.begin(), hosts.end(), url.host()) != hosts.end()) {
+ StartAsync(true);
+ return;
+ }
+ }
+
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&URLRequestChromeJob::CheckStoragePartitionMatches,
- render_process_id, request_->url(),
+ render_process_id, url,
weak_factory_.GetWeakPtr()));
+
TRACE_EVENT_ASYNC_BEGIN1("browser", "DataManager:Request", this, "URL",
Dan Beam 2016/05/19 06:46:26 btw, I'll move this to the top of the method tomor
- request_->url().possibly_invalid_spec());
+ url.possibly_invalid_spec());
}
void URLRequestChromeJob::Kill() {
@@ -396,25 +413,12 @@ void URLRequestChromeJob::CheckStoragePartitionMatches(
// exploited renderer pretending to add them as a subframe. We skip this check
// for resources.
bool allowed = false;
- std::vector<std::string> hosts;
- GetContentClient()->
- browser()->GetAdditionalWebUIHostsToIgnoreParititionCheck(&hosts);
- if (url.SchemeIs(kChromeUIScheme) &&
- (url.SchemeIs(kChromeUIScheme) ||
- std::find(hosts.begin(), hosts.end(), url.host()) != hosts.end())) {
- allowed = true;
- } else if (render_process_id == kNoRenderProcessId) {
- // Request was not issued by renderer.
- allowed = true;
- } else {
- RenderProcessHost* process = RenderProcessHost::FromID(render_process_id);
- if (process) {
- StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(
- process->GetBrowserContext(), url);
- allowed = partition == process->GetStoragePartition();
- }
+ RenderProcessHost* process = RenderProcessHost::FromID(render_process_id);
+ if (process) {
+ StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(
+ process->GetBrowserContext(), url);
+ allowed = partition == process->GetStoragePartition();
}
-
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698