OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 for (size_t thread_id = BrowserThread::UI + 1; | 312 for (size_t thread_id = BrowserThread::UI + 1; |
313 thread_id < BrowserThread::ID_COUNT; | 313 thread_id < BrowserThread::ID_COUNT; |
314 ++thread_id) { | 314 ++thread_id) { |
315 scoped_ptr<BrowserProcessSubThread>* thread_to_start = NULL; | 315 scoped_ptr<BrowserProcessSubThread>* thread_to_start = NULL; |
316 base::Thread::Options* options = &default_options; | 316 base::Thread::Options* options = &default_options; |
317 | 317 |
318 switch (thread_id) { | 318 switch (thread_id) { |
319 case BrowserThread::DB: | 319 case BrowserThread::DB: |
320 thread_to_start = &db_thread_; | 320 thread_to_start = &db_thread_; |
321 break; | 321 break; |
322 case BrowserThread::WEBKIT: | 322 case BrowserThread::WEBKIT_DEPRECATED: |
323 // Special case as WebKitThread is a separate | 323 // Special case as WebKitThread is a separate |
324 // type. |thread_to_start| is not used in this case. | 324 // type. |thread_to_start| is not used in this case. |
325 break; | 325 break; |
326 case BrowserThread::FILE_USER_BLOCKING: | 326 case BrowserThread::FILE_USER_BLOCKING: |
327 thread_to_start = &file_user_blocking_thread_; | 327 thread_to_start = &file_user_blocking_thread_; |
328 break; | 328 break; |
329 case BrowserThread::FILE: | 329 case BrowserThread::FILE: |
330 thread_to_start = &file_thread_; | 330 thread_to_start = &file_thread_; |
331 #if defined(OS_WIN) | 331 #if defined(OS_WIN) |
332 // On Windows, the FILE thread needs to be have a UI message loop | 332 // On Windows, the FILE thread needs to be have a UI message loop |
(...skipping 26 matching lines...) Expand all Loading... |
359 default: | 359 default: |
360 NOTREACHED(); | 360 NOTREACHED(); |
361 break; | 361 break; |
362 } | 362 } |
363 | 363 |
364 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); | 364 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); |
365 | 365 |
366 if (parts_.get()) | 366 if (parts_.get()) |
367 parts_->PreStartThread(id); | 367 parts_->PreStartThread(id); |
368 | 368 |
369 if (thread_id == BrowserThread::WEBKIT) { | 369 if (thread_id == BrowserThread::WEBKIT_DEPRECATED) { |
370 webkit_thread_.reset(new WebKitThread); | 370 webkit_thread_.reset(new WebKitThread); |
371 webkit_thread_->Initialize(); | 371 webkit_thread_->Initialize(); |
372 } else if (thread_to_start) { | 372 } else if (thread_to_start) { |
373 (*thread_to_start).reset(new BrowserProcessSubThread(id)); | 373 (*thread_to_start).reset(new BrowserProcessSubThread(id)); |
374 (*thread_to_start)->StartWithOptions(*options); | 374 (*thread_to_start)->StartWithOptions(*options); |
375 } else { | 375 } else { |
376 NOTREACHED(); | 376 NOTREACHED(); |
377 } | 377 } |
378 | 378 |
379 if (parts_.get()) | 379 if (parts_.get()) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // - The WEBKIT thread (which currently is the responsibility of | 441 // - The WEBKIT thread (which currently is the responsibility of |
442 // the embedder to stop, by destroying ResourceDispatcherHost | 442 // the embedder to stop, by destroying ResourceDispatcherHost |
443 // before the DB thread is stopped) | 443 // before the DB thread is stopped) |
444 // | 444 // |
445 // - (Not sure why DB stops last.) | 445 // - (Not sure why DB stops last.) |
446 scoped_ptr<BrowserProcessSubThread>* thread_to_stop = NULL; | 446 scoped_ptr<BrowserProcessSubThread>* thread_to_stop = NULL; |
447 switch (thread_id) { | 447 switch (thread_id) { |
448 case BrowserThread::DB: | 448 case BrowserThread::DB: |
449 thread_to_stop = &db_thread_; | 449 thread_to_stop = &db_thread_; |
450 break; | 450 break; |
451 case BrowserThread::WEBKIT: | 451 case BrowserThread::WEBKIT_DEPRECATED: |
452 // Special case as WebKitThread is a separate | 452 // Special case as WebKitThread is a separate |
453 // type. |thread_to_stop| is not used in this case. | 453 // type. |thread_to_stop| is not used in this case. |
454 break; | 454 break; |
455 case BrowserThread::FILE_USER_BLOCKING: | 455 case BrowserThread::FILE_USER_BLOCKING: |
456 thread_to_stop = &file_user_blocking_thread_; | 456 thread_to_stop = &file_user_blocking_thread_; |
457 break; | 457 break; |
458 case BrowserThread::FILE: | 458 case BrowserThread::FILE: |
459 thread_to_stop = &file_thread_; | 459 thread_to_stop = &file_thread_; |
460 break; | 460 break; |
461 case BrowserThread::PROCESS_LAUNCHER: | 461 case BrowserThread::PROCESS_LAUNCHER: |
(...skipping 15 matching lines...) Expand all Loading... |
477 default: | 477 default: |
478 NOTREACHED(); | 478 NOTREACHED(); |
479 break; | 479 break; |
480 } | 480 } |
481 | 481 |
482 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); | 482 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); |
483 | 483 |
484 if (parts_.get()) | 484 if (parts_.get()) |
485 parts_->PreStopThread(id); | 485 parts_->PreStopThread(id); |
486 | 486 |
487 if (id == BrowserThread::WEBKIT) { | 487 if (id == BrowserThread::WEBKIT_DEPRECATED) { |
488 webkit_thread_.reset(); | 488 webkit_thread_.reset(); |
489 } else if (thread_to_stop) { | 489 } else if (thread_to_stop) { |
490 thread_to_stop->reset(); | 490 thread_to_stop->reset(); |
491 } else { | 491 } else { |
492 NOTREACHED(); | 492 NOTREACHED(); |
493 } | 493 } |
494 | 494 |
495 if (parts_.get()) | 495 if (parts_.get()) |
496 parts_->PostStopThread(id); | 496 parts_->PostStopThread(id); |
497 } | 497 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 MessageLoopForUI::current()->PostTask(FROM_HERE, parameters_.ui_task); | 559 MessageLoopForUI::current()->PostTask(FROM_HERE, parameters_.ui_task); |
560 | 560 |
561 #if defined(OS_MACOSX) | 561 #if defined(OS_MACOSX) |
562 MessageLoopForUI::current()->Run(); | 562 MessageLoopForUI::current()->Run(); |
563 #else | 563 #else |
564 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 564 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
565 #endif | 565 #endif |
566 } | 566 } |
567 | 567 |
568 } // namespace content | 568 } // namespace content |
OLD | NEW |