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

Side by Side Diff: content/browser/resource_context_impl.cc

Issue 1600263002: Post a task to the IO thread to add a ResourceContext in ResourceDispatcherHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move task posting to call site. Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/resource_context_impl.h" 5 #include "content/browser/resource_context_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" 11 #include "content/browser/fileapi/chrome_blob_storage_context.h"
11 #include "content/browser/loader/resource_dispatcher_host_impl.h" 12 #include "content/browser/loader/resource_dispatcher_host_impl.h"
12 #include "content/browser/loader/resource_request_info_impl.h" 13 #include "content/browser/loader/resource_request_info_impl.h"
13 #include "content/browser/streams/stream_context.h" 14 #include "content/browser/streams/stream_context.h"
14 #include "content/browser/webui/url_data_manager_backend.h" 15 #include "content/browser/webui/url_data_manager_backend.h"
15 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "net/base/keygen_handler.h" 18 #include "net/base/keygen_handler.h"
18 #include "net/ssl/client_cert_store.h" 19 #include "net/ssl/client_cert_store.h"
(...skipping 11 matching lines...) Expand all
30 31
31 // Used by the default implementation of GetMediaDeviceIDSalt, below. 32 // Used by the default implementation of GetMediaDeviceIDSalt, below.
32 std::string ReturnEmptySalt() { 33 std::string ReturnEmptySalt() {
33 return std::string(); 34 return std::string();
34 } 35 }
35 36
36 } // namespace 37 } // namespace
37 38
38 39
39 ResourceContext::ResourceContext() { 40 ResourceContext::ResourceContext() {
40 if (ResourceDispatcherHostImpl::Get()) 41 ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get();
41 ResourceDispatcherHostImpl::Get()->AddResourceContext(this); 42 if (rdhi) {
43 BrowserThread::PostTask(
44 BrowserThread::IO, FROM_HERE,
45 base::Bind(&ResourceDispatcherHostImpl::AddResourceContext,
46 base::Unretained(rdhi), this));
47 }
42 } 48 }
43 49
44 ResourceContext::~ResourceContext() { 50 ResourceContext::~ResourceContext() {
45 ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get(); 51 ResourceDispatcherHostImpl* rdhi = ResourceDispatcherHostImpl::Get();
46 if (rdhi) { 52 if (rdhi) {
47 rdhi->CancelRequestsForContext(this); 53 rdhi->CancelRequestsForContext(this);
48 rdhi->RemoveResourceContext(this); 54 rdhi->RemoveResourceContext(this);
49 } 55 }
50 56
51 // In some tests this object is destructed on UI thread. 57 // In some tests this object is destructed on UI thread.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 110
105 resource_context->SetUserData( 111 resource_context->SetUserData(
106 kStreamContextKeyName, 112 kStreamContextKeyName,
107 new UserDataAdapter<StreamContext>( 113 new UserDataAdapter<StreamContext>(
108 StreamContext::GetFor(browser_context))); 114 StreamContext::GetFor(browser_context)));
109 115
110 resource_context->DetachUserDataThread(); 116 resource_context->DetachUserDataThread();
111 } 117 }
112 118
113 } // namespace content 119 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698