| OLD | NEW |
| 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/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/hi_res_timer_manager.h" | 10 #include "base/hi_res_timer_manager.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| 40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
| 41 #include "content/public/common/main_function_params.h" | 41 #include "content/public/common/main_function_params.h" |
| 42 #include "content/public/common/result_codes.h" | 42 #include "content/public/common/result_codes.h" |
| 43 #include "crypto/nss_util.h" | 43 #include "crypto/nss_util.h" |
| 44 #include "media/audio/audio_manager.h" | 44 #include "media/audio/audio_manager.h" |
| 45 #include "net/base/network_change_notifier.h" | 45 #include "net/base/network_change_notifier.h" |
| 46 #include "net/base/ssl_config_service.h" | 46 #include "net/base/ssl_config_service.h" |
| 47 #include "net/socket/client_socket_factory.h" | 47 #include "net/socket/client_socket_factory.h" |
| 48 #include "net/socket/tcp_client_socket.h" | 48 #include "net/socket/tcp_client_socket.h" |
| 49 #include "ui/base/clipboard/clipboard.h" |
| 49 | 50 |
| 50 #if defined(USE_AURA) | 51 #if defined(USE_AURA) |
| 51 #include "content/browser/renderer_host/image_transport_factory.h" | 52 #include "content/browser/renderer_host/image_transport_factory.h" |
| 52 #endif | 53 #endif |
| 53 | 54 |
| 54 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
| 55 #include <windows.h> | 56 #include <windows.h> |
| 56 #include <commctrl.h> | 57 #include <commctrl.h> |
| 57 #include <shellapi.h> | 58 #include <shellapi.h> |
| 58 | 59 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) | 230 BrowserMainLoop::BrowserMainLoop(const content::MainFunctionParams& parameters) |
| 230 : parameters_(parameters), | 231 : parameters_(parameters), |
| 231 parsed_command_line_(parameters.command_line), | 232 parsed_command_line_(parameters.command_line), |
| 232 result_code_(content::RESULT_CODE_NORMAL_EXIT) { | 233 result_code_(content::RESULT_CODE_NORMAL_EXIT) { |
| 233 DCHECK(!g_current_browser_main_loop); | 234 DCHECK(!g_current_browser_main_loop); |
| 234 g_current_browser_main_loop = this; | 235 g_current_browser_main_loop = this; |
| 235 } | 236 } |
| 236 | 237 |
| 237 BrowserMainLoop::~BrowserMainLoop() { | 238 BrowserMainLoop::~BrowserMainLoop() { |
| 238 DCHECK_EQ(this, g_current_browser_main_loop); | 239 DCHECK_EQ(this, g_current_browser_main_loop); |
| 240 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 239 g_current_browser_main_loop = NULL; | 241 g_current_browser_main_loop = NULL; |
| 240 } | 242 } |
| 241 | 243 |
| 242 void BrowserMainLoop::Init() { | 244 void BrowserMainLoop::Init() { |
| 243 parts_.reset( | 245 parts_.reset( |
| 244 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); | 246 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); |
| 245 } | 247 } |
| 246 | 248 |
| 247 // BrowserMainLoop stages ================================================== | 249 // BrowserMainLoop stages ================================================== |
| 248 | 250 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); | 660 resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); |
| 659 | 661 |
| 660 // Start the GpuDataManager before we set up the MessageLoops because | 662 // Start the GpuDataManager before we set up the MessageLoops because |
| 661 // otherwise we'll trigger the assertion about doing IO on the UI thread. | 663 // otherwise we'll trigger the assertion about doing IO on the UI thread. |
| 662 content::GpuDataManager::GetInstance(); | 664 content::GpuDataManager::GetInstance(); |
| 663 #endif // !OS_IOS | 665 #endif // !OS_IOS |
| 664 | 666 |
| 665 #if defined(ENABLE_INPUT_SPEECH) | 667 #if defined(ENABLE_INPUT_SPEECH) |
| 666 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); | 668 speech_recognition_manager_.reset(new speech::SpeechRecognitionManagerImpl()); |
| 667 #endif | 669 #endif |
| 670 |
| 671 // Alert the clipboard class to which threads are allowed to access the |
| 672 // clipboard: |
| 673 std::vector<base::PlatformThreadId> allowed_clipboard_threads; |
| 674 // The current thread is the UI thread. |
| 675 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); |
| 676 #if defined(OS_WIN) |
| 677 // On Windows, clipboards are also used on the File or IO threads. |
| 678 allowed_clipboard_threads.push_back(file_thread_->thread_id()); |
| 679 allowed_clipboard_threads.push_back(io_thread_->thread_id()); |
| 680 #endif |
| 681 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); |
| 668 } | 682 } |
| 669 | 683 |
| 670 void BrowserMainLoop::InitializeToolkit() { | 684 void BrowserMainLoop::InitializeToolkit() { |
| 671 // TODO(evan): this function is rather subtle, due to the variety | 685 // TODO(evan): this function is rather subtle, due to the variety |
| 672 // of intersecting ifdefs we have. To keep it easy to follow, there | 686 // of intersecting ifdefs we have. To keep it easy to follow, there |
| 673 // are no #else branches on any #ifs. | 687 // are no #else branches on any #ifs. |
| 674 // TODO(stevenjb): Move platform specific code into platform specific Parts | 688 // TODO(stevenjb): Move platform specific code into platform specific Parts |
| 675 // (Need to add InitializeToolkit stage to BrowserParts). | 689 // (Need to add InitializeToolkit stage to BrowserParts). |
| 676 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 690 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 677 // Glib type system initialization. Needed at least for gconf, | 691 // Glib type system initialization. Needed at least for gconf, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 729 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
| 716 if (parameters_.ui_task) | 730 if (parameters_.ui_task) |
| 717 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); | 731 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); |
| 718 | 732 |
| 719 base::RunLoop run_loop; | 733 base::RunLoop run_loop; |
| 720 run_loop.Run(); | 734 run_loop.Run(); |
| 721 #endif | 735 #endif |
| 722 } | 736 } |
| 723 | 737 |
| 724 } // namespace content | 738 } // namespace content |
| OLD | NEW |