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

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Charlie's comments. Created 7 years, 9 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
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 "chrome/browser/profiles/profile_impl_io_data.h" 5 #include "chrome/browser/profiles/profile_impl_io_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
123 // Don't call LazyInitialize here, since the resource context is created at 123 // Don't call LazyInitialize here, since the resource context is created at
124 // the beginning of initalization and is used by some members while they're 124 // the beginning of initalization and is used by some members while they're
125 // being initialized (i.e. AppCacheService). 125 // being initialized (i.e. AppCacheService).
126 return io_data_->GetResourceContext(); 126 return io_data_->GetResourceContext();
127 } 127 }
128 128
129 scoped_refptr<ChromeURLRequestContextGetter> 129 scoped_refptr<ChromeURLRequestContextGetter>
130 ProfileImplIOData::Handle::CreateMainRequestContextGetter( 130 ProfileImplIOData::Handle::CreateMainRequestContextGetter(
131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 131 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
132 blob_protocol_handler,
133 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
134 file_system_protocol_handler,
135 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
136 developer_protocol_handler, 132 developer_protocol_handler,
137 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 133 content::ProtocolHandlerMap* protocol_handlers,
138 chrome_protocol_handler,
139 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
140 chrome_devtools_protocol_handler,
141 PrefService* local_state, 134 PrefService* local_state,
142 IOThread* io_thread) const { 135 IOThread* io_thread) const {
143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
144 LazyInitialize(); 137 LazyInitialize();
145 DCHECK(!main_request_context_getter_); 138 DCHECK(!main_request_context_getter_);
146 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal( 139 main_request_context_getter_ = ChromeURLRequestContextGetter::CreateOriginal(
147 profile_, io_data_, blob_protocol_handler.Pass(), 140 profile_, io_data_, developer_protocol_handler.Pass(),
148 file_system_protocol_handler.Pass(), developer_protocol_handler.Pass(), 141 protocol_handlers);
149 chrome_protocol_handler.Pass(), chrome_devtools_protocol_handler.Pass());
150 142
151 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(), 143 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs(),
152 local_state, 144 local_state,
153 io_thread, 145 io_thread,
154 main_request_context_getter_); 146 main_request_context_getter_);
155 147
156 content::NotificationService::current()->Notify( 148 content::NotificationService::current()->Notify(
157 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, 149 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
158 content::Source<Profile>(profile_), 150 content::Source<Profile>(profile_),
159 content::NotificationService::NoDetails()); 151 content::NotificationService::NoDetails());
(...skipping 22 matching lines...) Expand all
182 profile_, io_data_); 174 profile_, io_data_);
183 } 175 }
184 return extensions_request_context_getter_; 176 return extensions_request_context_getter_;
185 } 177 }
186 178
187 scoped_refptr<ChromeURLRequestContextGetter> 179 scoped_refptr<ChromeURLRequestContextGetter>
188 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( 180 ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter(
189 const base::FilePath& partition_path, 181 const base::FilePath& partition_path,
190 bool in_memory, 182 bool in_memory,
191 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 183 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
192 blob_protocol_handler,
193 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
194 file_system_protocol_handler,
195 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
196 developer_protocol_handler, 184 developer_protocol_handler,
197 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 185 content::ProtocolHandlerMap* protocol_handlers) const {
198 chrome_protocol_handler,
199 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
200 chrome_devtools_protocol_handler) const {
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
202 // Check that the partition_path is not the same as the base profile path. We 187 // Check that the partition_path is not the same as the base profile path. We
203 // expect isolated partition, which will never go to the default profile path. 188 // expect isolated partition, which will never go to the default profile path.
204 CHECK(partition_path != profile_->GetPath()); 189 CHECK(partition_path != profile_->GetPath());
205 LazyInitialize(); 190 LazyInitialize();
206 191
207 // Keep a map of request context getters, one per requested storage partition. 192 // Keep a map of request context getters, one per requested storage partition.
208 StoragePartitionDescriptor descriptor(partition_path, in_memory); 193 StoragePartitionDescriptor descriptor(partition_path, in_memory);
209 ChromeURLRequestContextGetterMap::iterator iter = 194 ChromeURLRequestContextGetterMap::iterator iter =
210 app_request_context_getter_map_.find(descriptor); 195 app_request_context_getter_map_.find(descriptor);
211 if (iter != app_request_context_getter_map_.end()) 196 if (iter != app_request_context_getter_map_.end())
212 return iter->second; 197 return iter->second;
213 198
214 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 199 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
215 protocol_handler_interceptor( 200 protocol_handler_interceptor(
216 ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> 201 ProtocolHandlerRegistryFactory::GetForProfile(profile_)->
217 CreateJobInterceptorFactory()); 202 CreateJobInterceptorFactory());
218 ChromeURLRequestContextGetter* context = 203 ChromeURLRequestContextGetter* context =
219 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( 204 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
220 profile_, io_data_, descriptor, 205 profile_, io_data_, descriptor,
221 protocol_handler_interceptor.Pass(), blob_protocol_handler.Pass(), 206 protocol_handler_interceptor.Pass(),
222 file_system_protocol_handler.Pass(), 207 developer_protocol_handler.Pass(),
223 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), 208 protocol_handlers);
224 chrome_devtools_protocol_handler.Pass());
225 app_request_context_getter_map_[descriptor] = context; 209 app_request_context_getter_map_[descriptor] = context;
226 210
227 return context; 211 return context;
228 } 212 }
229 213
230 scoped_refptr<ChromeURLRequestContextGetter> 214 scoped_refptr<ChromeURLRequestContextGetter>
231 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter( 215 ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter(
232 const base::FilePath& partition_path, 216 const base::FilePath& partition_path,
233 bool in_memory) const { 217 bool in_memory) const {
234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 ProfileImplIOData::~ProfileImplIOData() { 295 ProfileImplIOData::~ProfileImplIOData() {
312 DestroyResourceContext(); 296 DestroyResourceContext();
313 297
314 if (media_request_context_.get()) 298 if (media_request_context_.get())
315 media_request_context_->AssertNoURLRequests(); 299 media_request_context_->AssertNoURLRequests();
316 } 300 }
317 301
318 void ProfileImplIOData::InitializeInternal( 302 void ProfileImplIOData::InitializeInternal(
319 ProfileParams* profile_params, 303 ProfileParams* profile_params,
320 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 304 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
321 blob_protocol_handler,
322 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
323 file_system_protocol_handler,
324 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
325 developer_protocol_handler, 305 developer_protocol_handler,
326 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 306 content::ProtocolHandlerMap* protocol_handlers) const {
327 chrome_protocol_handler,
328 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
329 chrome_devtools_protocol_handler) const {
330 ChromeURLRequestContext* main_context = main_request_context(); 307 ChromeURLRequestContext* main_context = main_request_context();
331 308
332 IOThread* const io_thread = profile_params->io_thread; 309 IOThread* const io_thread = profile_params->io_thread;
333 IOThread::Globals* const io_thread_globals = io_thread->globals(); 310 IOThread::Globals* const io_thread_globals = io_thread->globals();
334 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 311 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
335 // Only allow Record Mode if we are in a Debug build or where we are running 312 // Only allow Record Mode if we are in a Debug build or where we are running
336 // a cycle, and the user has limited control. 313 // a cycle, and the user has limited control.
337 bool record_mode = command_line.HasSwitch(switches::kRecordMode) && 314 bool record_mode = command_line.HasSwitch(switches::kRecordMode) &&
338 (chrome::kRecordModeEnabled || 315 (chrome::kRecordModeEnabled ||
339 command_line.HasSwitch(switches::kVisitURLs)); 316 command_line.HasSwitch(switches::kVisitURLs));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 main_context->set_http_transaction_factory(main_cache); 417 main_context->set_http_transaction_factory(main_cache);
441 418
442 #if !defined(DISABLE_FTP_SUPPORT) 419 #if !defined(DISABLE_FTP_SUPPORT)
443 ftp_factory_.reset( 420 ftp_factory_.reset(
444 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 421 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
445 main_context->set_ftp_transaction_factory(ftp_factory_.get()); 422 main_context->set_ftp_transaction_factory(ftp_factory_.get());
446 #endif // !defined(DISABLE_FTP_SUPPORT) 423 #endif // !defined(DISABLE_FTP_SUPPORT)
447 424
448 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( 425 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
449 new net::URLRequestJobFactoryImpl()); 426 new net::URLRequestJobFactoryImpl());
450 bool set_protocol = main_job_factory->SetProtocolHandler( 427 content::ContentBrowserClient::InstallProtocolHandlers(main_job_factory.get(),
451 chrome::kBlobScheme, blob_protocol_handler.release()); 428 protocol_handlers);
452 DCHECK(set_protocol);
453 set_protocol = main_job_factory->SetProtocolHandler(
454 chrome::kFileSystemScheme, file_system_protocol_handler.release());
455 DCHECK(set_protocol);
456 set_protocol = main_job_factory->SetProtocolHandler(
457 chrome::kChromeUIScheme, chrome_protocol_handler.release());
458 DCHECK(set_protocol);
459 set_protocol = main_job_factory->SetProtocolHandler(
460 chrome::kChromeDevToolsScheme,
461 chrome_devtools_protocol_handler.release());
462 DCHECK(set_protocol);
463 main_job_factory_ = SetUpJobFactoryDefaults( 429 main_job_factory_ = SetUpJobFactoryDefaults(
464 main_job_factory.Pass(), 430 main_job_factory.Pass(),
465 profile_params->protocol_handler_interceptor.Pass(), 431 profile_params->protocol_handler_interceptor.Pass(),
466 network_delegate(), 432 network_delegate(),
467 main_context->ftp_transaction_factory(), 433 main_context->ftp_transaction_factory(),
468 main_context->ftp_auth_cache()); 434 main_context->ftp_auth_cache());
469 main_job_factory_.reset(new net::ProtocolInterceptJobFactory( 435 main_job_factory_.reset(new net::ProtocolInterceptJobFactory(
470 main_job_factory_.Pass(), developer_protocol_handler.Pass())); 436 main_job_factory_.Pass(), developer_protocol_handler.Pass()));
471 main_context->set_job_factory(main_job_factory_.get()); 437 main_context->set_job_factory(main_job_factory_.get());
472 438
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 extensions_context->set_job_factory(extensions_job_factory_.get()); 499 extensions_context->set_job_factory(extensions_job_factory_.get());
534 } 500 }
535 501
536 ChromeURLRequestContext* 502 ChromeURLRequestContext*
537 ProfileImplIOData::InitializeAppRequestContext( 503 ProfileImplIOData::InitializeAppRequestContext(
538 ChromeURLRequestContext* main_context, 504 ChromeURLRequestContext* main_context,
539 const StoragePartitionDescriptor& partition_descriptor, 505 const StoragePartitionDescriptor& partition_descriptor,
540 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 506 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
541 protocol_handler_interceptor, 507 protocol_handler_interceptor,
542 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 508 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
543 blob_protocol_handler,
544 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
545 file_system_protocol_handler,
546 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
547 developer_protocol_handler, 509 developer_protocol_handler,
548 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 510 content::ProtocolHandlerMap* protocol_handlers) const {
549 chrome_protocol_handler,
550 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
551 chrome_devtools_protocol_handler) const {
552 // Copy most state from the main context. 511 // Copy most state from the main context.
553 AppRequestContext* context = new AppRequestContext(load_time_stats()); 512 AppRequestContext* context = new AppRequestContext(load_time_stats());
554 context->CopyFrom(main_context); 513 context->CopyFrom(main_context);
555 514
556 base::FilePath cookie_path = partition_descriptor.path.Append( 515 base::FilePath cookie_path = partition_descriptor.path.Append(
557 chrome::kCookieFilename); 516 chrome::kCookieFilename);
558 base::FilePath cache_path = 517 base::FilePath cache_path =
559 partition_descriptor.path.Append(chrome::kCacheDirname); 518 partition_descriptor.path.Append(chrome::kCacheDirname);
560 519
561 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 520 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 cookie_store = new net::CookieMonster(cookie_db.get(), NULL); 572 cookie_store = new net::CookieMonster(cookie_db.get(), NULL);
614 } 573 }
615 574
616 // Transfer ownership of the cookies and cache to AppRequestContext. 575 // Transfer ownership of the cookies and cache to AppRequestContext.
617 context->SetCookieStore(cookie_store); 576 context->SetCookieStore(cookie_store);
618 context->SetHttpTransactionFactory( 577 context->SetHttpTransactionFactory(
619 scoped_ptr<net::HttpTransactionFactory>(app_http_cache)); 578 scoped_ptr<net::HttpTransactionFactory>(app_http_cache));
620 579
621 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 580 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
622 new net::URLRequestJobFactoryImpl()); 581 new net::URLRequestJobFactoryImpl());
623 bool set_protocol = job_factory->SetProtocolHandler( 582 content::ContentBrowserClient::InstallProtocolHandlers(job_factory.get(),
624 chrome::kBlobScheme, blob_protocol_handler.release()); 583 protocol_handlers);
625 DCHECK(set_protocol);
626 set_protocol = job_factory->SetProtocolHandler(
627 chrome::kFileSystemScheme, file_system_protocol_handler.release());
628 DCHECK(set_protocol);
629 set_protocol = job_factory->SetProtocolHandler(
630 chrome::kChromeUIScheme, chrome_protocol_handler.release());
631 DCHECK(set_protocol);
632 set_protocol = job_factory->SetProtocolHandler(
633 chrome::kChromeDevToolsScheme,
634 chrome_devtools_protocol_handler.release());
635 DCHECK(set_protocol);
636 scoped_ptr<net::URLRequestJobFactory> top_job_factory; 584 scoped_ptr<net::URLRequestJobFactory> top_job_factory;
637 // Overwrite the job factory that we inherit from the main context so 585 // Overwrite the job factory that we inherit from the main context so
638 // that we can later provide our own handlers for storage related protocols. 586 // that we can later provide our own handlers for storage related protocols.
639 // Install all the usual protocol handlers unless we are in a browser plugin 587 // Install all the usual protocol handlers unless we are in a browser plugin
640 // guest process, in which case only web-safe schemes are allowed. 588 // guest process, in which case only web-safe schemes are allowed.
641 if (!partition_descriptor.in_memory) { 589 if (!partition_descriptor.in_memory) {
642 top_job_factory = SetUpJobFactoryDefaults( 590 top_job_factory = SetUpJobFactoryDefaults(
643 job_factory.Pass(), protocol_handler_interceptor.Pass(), 591 job_factory.Pass(), protocol_handler_interceptor.Pass(),
644 network_delegate(), 592 network_delegate(),
645 context->ftp_transaction_factory(), 593 context->ftp_transaction_factory(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 return media_request_context_.get(); 656 return media_request_context_.get();
709 } 657 }
710 658
711 ChromeURLRequestContext* 659 ChromeURLRequestContext*
712 ProfileImplIOData::AcquireIsolatedAppRequestContext( 660 ProfileImplIOData::AcquireIsolatedAppRequestContext(
713 ChromeURLRequestContext* main_context, 661 ChromeURLRequestContext* main_context,
714 const StoragePartitionDescriptor& partition_descriptor, 662 const StoragePartitionDescriptor& partition_descriptor,
715 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 663 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
716 protocol_handler_interceptor, 664 protocol_handler_interceptor,
717 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 665 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
718 blob_protocol_handler,
719 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
720 file_system_protocol_handler,
721 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
722 developer_protocol_handler, 666 developer_protocol_handler,
723 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 667 content::ProtocolHandlerMap* protocol_handlers) const {
724 chrome_protocol_handler,
725 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
726 chrome_devtools_protocol_handler) const {
727 // We create per-app contexts on demand, unlike the others above. 668 // We create per-app contexts on demand, unlike the others above.
728 ChromeURLRequestContext* app_request_context = 669 ChromeURLRequestContext* app_request_context =
729 InitializeAppRequestContext(main_context, partition_descriptor, 670 InitializeAppRequestContext(main_context, partition_descriptor,
730 protocol_handler_interceptor.Pass(), 671 protocol_handler_interceptor.Pass(),
731 blob_protocol_handler.Pass(),
732 file_system_protocol_handler.Pass(),
733 developer_protocol_handler.Pass(), 672 developer_protocol_handler.Pass(),
734 chrome_protocol_handler.Pass(), 673 protocol_handlers);
735 chrome_devtools_protocol_handler.Pass());
736 DCHECK(app_request_context); 674 DCHECK(app_request_context);
737 return app_request_context; 675 return app_request_context;
738 } 676 }
739 677
740 ChromeURLRequestContext* 678 ChromeURLRequestContext*
741 ProfileImplIOData::AcquireIsolatedMediaRequestContext( 679 ProfileImplIOData::AcquireIsolatedMediaRequestContext(
742 ChromeURLRequestContext* app_context, 680 ChromeURLRequestContext* app_context,
743 const StoragePartitionDescriptor& partition_descriptor) const { 681 const StoragePartitionDescriptor& partition_descriptor) const {
744 // We create per-app media contexts on demand, unlike the others above. 682 // We create per-app media contexts on demand, unlike the others above.
745 ChromeURLRequestContext* media_request_context = 683 ChromeURLRequestContext* media_request_context =
(...skipping 11 matching lines...) Expand all
757 base::Time time, 695 base::Time time,
758 const base::Closure& completion) { 696 const base::Closure& completion) {
759 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
760 DCHECK(initialized()); 698 DCHECK(initialized());
761 699
762 DCHECK(transport_security_state()); 700 DCHECK(transport_security_state());
763 transport_security_state()->DeleteSince(time); // Completes synchronously. 701 transport_security_state()->DeleteSince(time); // Completes synchronously.
764 DCHECK(http_server_properties_manager_); 702 DCHECK(http_server_properties_manager_);
765 http_server_properties_manager_->Clear(completion); 703 http_server_properties_manager_->Clear(completion);
766 } 704 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698