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

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

Issue 10916214: Try 2 - Change how ui::Clipboard is accessed so there's only one per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows STL requires <iterator> Created 8 years, 3 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 "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
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
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 base::IgnoreResult(&GpuProcessHost::Get), 467 base::IgnoreResult(&GpuProcessHost::Get),
466 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, 468 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
467 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); 469 content::CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP));
468 } 470 }
469 #endif // !defined(OS_IOS) 471 #endif // !defined(OS_IOS)
470 472
471 // If the UI thread blocks, the whole UI is unresponsive. 473 // If the UI thread blocks, the whole UI is unresponsive.
472 // Do not allow disk IO from the UI thread. 474 // Do not allow disk IO from the UI thread.
473 base::ThreadRestrictions::SetIOAllowed(false); 475 base::ThreadRestrictions::SetIOAllowed(false);
474 base::ThreadRestrictions::DisallowWaiting(); 476 base::ThreadRestrictions::DisallowWaiting();
477
478 // Alert the clipboard class to which threads are allowed to access the
jam 2012/09/10 22:44:19 please move this to BrowserThreadsStarted since th
479 // clipboard:
480 std::vector<base::PlatformThreadId> allowed_clipboard_threads;
481 // The current thread is the UI thread.
482 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId());
483 #if defined(OS_WIN)
484 // On Windows, clipboards are also used on the File or IO threads.
485 allowed_clipboard_threads.push_back(file_thread_->thread_id());
486 allowed_clipboard_threads.push_back(io_thread_->thread_id());
487 #endif
488 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads);
475 } 489 }
476 490
477 void BrowserMainLoop::RunMainMessageLoopParts() { 491 void BrowserMainLoop::RunMainMessageLoopParts() {
478 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); 492 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, "");
479 493
480 bool ran_main_loop = false; 494 bool ran_main_loop = false;
481 if (parts_.get()) 495 if (parts_.get())
482 ran_main_loop = parts_->MainMessageLoopRun(&result_code_); 496 ran_main_loop = parts_->MainMessageLoopRun(&result_code_);
483 497
484 if (!ran_main_loop) 498 if (!ran_main_loop)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_test_utils.cc ('k') | content/browser/renderer_host/clipboard_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698