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

Side by Side Diff: chrome/browser/chrome_plugin_host.cc

Issue 258008: Move initialization of ChromeURLRequestContexts to the IO thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again, just in case Created 11 years, 1 month 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 | « chrome/browser/browsing_data_remover.cc ('k') | chrome/browser/cookies_table_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/chrome_plugin_host.h" 5 #include "chrome/browser/chrome_plugin_host.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/histogram.h" 13 #include "base/histogram.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/perftimer.h" 16 #include "base/perftimer.h"
17 #include "base/singleton.h" 17 #include "base/singleton.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "chrome/browser/browser_list.h" 19 #include "chrome/browser/browser_list.h"
20 #include "chrome/browser/chrome_plugin_browsing_context.h" 20 #include "chrome/browser/chrome_plugin_browsing_context.h"
21 #include "chrome/browser/chrome_thread.h" 21 #include "chrome/browser/chrome_thread.h"
22 #include "chrome/browser/dom_ui/html_dialog_ui.h" 22 #include "chrome/browser/dom_ui/html_dialog_ui.h"
23 #include "chrome/browser/gears_integration.h" 23 #include "chrome/browser/gears_integration.h"
24 #include "chrome/browser/net/url_request_context_getter.h"
24 #include "chrome/browser/plugin_process_host.h" 25 #include "chrome/browser/plugin_process_host.h"
25 #include "chrome/browser/plugin_service.h" 26 #include "chrome/browser/plugin_service.h"
26 #include "chrome/browser/profile.h" 27 #include "chrome/browser/profile.h"
27 #include "chrome/browser/renderer_host/render_process_host.h" 28 #include "chrome/browser/renderer_host/render_process_host.h"
28 #include "chrome/common/chrome_constants.h" 29 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_counters.h" 30 #include "chrome/common/chrome_counters.h"
30 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_plugin_lib.h" 32 #include "chrome/common/chrome_plugin_lib.h"
32 #include "chrome/common/chrome_plugin_util.h" 33 #include "chrome/common/chrome_plugin_util.h"
33 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 151 }
151 152
152 PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest) 153 PluginRequestHandler(ChromePluginLib* plugin, ScopableCPRequest* cprequest)
153 : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) { 154 : PluginHelper(plugin), cprequest_(cprequest), user_buffer_(NULL) {
154 cprequest_->data = this; // see FromCPRequest(). 155 cprequest_->data = this; // see FromCPRequest().
155 156
156 URLRequestContext* context = CPBrowsingContextManager::Instance()-> 157 URLRequestContext* context = CPBrowsingContextManager::Instance()->
157 ToURLRequestContext(cprequest_->context); 158 ToURLRequestContext(cprequest_->context);
158 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. 159 // TODO(mpcomplete): remove fallback case when Gears support is prevalent.
159 if (!context) 160 if (!context)
160 context = Profile::GetDefaultRequestContext(); 161 context = Profile::GetDefaultRequestContext()->GetURLRequestContext();
161 162
162 GURL gurl(cprequest_->url); 163 GURL gurl(cprequest_->url);
163 request_.reset(new URLRequest(gurl, this)); 164 request_.reset(new URLRequest(gurl, this));
164 request_->set_context(context); 165 request_->set_context(context);
165 request_->set_method(cprequest_->method); 166 request_->set_method(cprequest_->method);
166 request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0)); 167 request_->set_load_flags(PluginResponseUtils::CPLoadFlagsToNetFlags(0));
167 } 168 }
168 169
169 URLRequest* request() { return request_.get(); } 170 URLRequest* request() { return request_.get(); }
170 171
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // This is a no-op in the main browser process 383 // This is a no-op in the main browser process
383 } 384 }
384 385
385 CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext, 386 CPError STDCALL CPB_GetCookies(CPID id, CPBrowsingContext bcontext,
386 const char* url, char** cookies) { 387 const char* url, char** cookies) {
387 CHECK(ChromePluginLib::IsPluginThread()); 388 CHECK(ChromePluginLib::IsPluginThread());
388 URLRequestContext* context = CPBrowsingContextManager::Instance()-> 389 URLRequestContext* context = CPBrowsingContextManager::Instance()->
389 ToURLRequestContext(bcontext); 390 ToURLRequestContext(bcontext);
390 // TODO(mpcomplete): remove fallback case when Gears support is prevalent. 391 // TODO(mpcomplete): remove fallback case when Gears support is prevalent.
391 if (!context) { 392 if (!context) {
392 context = Profile::GetDefaultRequestContext(); 393 context = Profile::GetDefaultRequestContext()->GetURLRequestContext();
393 if (!context) 394 if (!context)
394 return CPERR_FAILURE; 395 return CPERR_FAILURE;
395 } 396 }
396 std::string cookies_str = context->cookie_store()->GetCookies(GURL(url)); 397 std::string cookies_str = context->cookie_store()->GetCookies(GURL(url));
397 *cookies = CPB_StringDup(CPB_Alloc, cookies_str); 398 *cookies = CPB_StringDup(CPB_Alloc, cookies_str);
398 return CPERR_SUCCESS; 399 return CPERR_SUCCESS;
399 } 400 }
400 401
401 CPError STDCALL CPB_ShowHtmlDialogModal( 402 CPError STDCALL CPB_ShowHtmlDialogModal(
402 CPID id, CPBrowsingContext context, const char* url, int width, int height, 403 CPID id, CPBrowsingContext context, const char* url, int width, int height,
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 void CPHandleCommand(int command, CPCommandInterface* data, 817 void CPHandleCommand(int command, CPCommandInterface* data,
817 CPBrowsingContext context) { 818 CPBrowsingContext context) {
818 // Sadly if we try and pass context through, we seem to break cl's little 819 // Sadly if we try and pass context through, we seem to break cl's little
819 // brain trying to compile the Tuple3 ctor. This cast works. 820 // brain trying to compile the Tuple3 ctor. This cast works.
820 int32 context_as_int32 = static_cast<int32>(context); 821 int32 context_as_int32 = static_cast<int32>(context);
821 // Plugins can only be accessed on the IO thread. 822 // Plugins can only be accessed on the IO thread.
822 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 823 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
823 NewRunnableFunction(PluginCommandHandler::HandleCommand, 824 NewRunnableFunction(PluginCommandHandler::HandleCommand,
824 command, data, context_as_int32)); 825 command, data, context_as_int32));
825 } 826 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_remover.cc ('k') | chrome/browser/cookies_table_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698