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

Side by Side Diff: chrome/browser/devtools/device/android_device_manager.cc

Issue 1030263002: favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | chrome/browser/devtools/device/android_web_socket.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/device/android_device_manager.h" 5 #include "chrome/browser/devtools/device/android_device_manager.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 base::Unretained(raw_ptr), 426 base::Unretained(raw_ptr),
427 serial_)); 427 serial_));
428 } 428 }
429 429
430 AndroidDeviceManager::HandlerThread* 430 AndroidDeviceManager::HandlerThread*
431 AndroidDeviceManager::HandlerThread::instance_ = NULL; 431 AndroidDeviceManager::HandlerThread::instance_ = NULL;
432 432
433 // static 433 // static
434 scoped_refptr<AndroidDeviceManager::HandlerThread> 434 scoped_refptr<AndroidDeviceManager::HandlerThread>
435 AndroidDeviceManager::HandlerThread::GetInstance() { 435 AndroidDeviceManager::HandlerThread::GetInstance() {
436 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 436 DCHECK_CURRENTLY_ON(BrowserThread::UI);
437 if (!instance_) 437 if (!instance_)
438 new HandlerThread(); 438 new HandlerThread();
439 return instance_; 439 return instance_;
440 } 440 }
441 441
442 AndroidDeviceManager::HandlerThread::HandlerThread() { 442 AndroidDeviceManager::HandlerThread::HandlerThread() {
443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 443 DCHECK_CURRENTLY_ON(BrowserThread::UI);
444 instance_ = this; 444 instance_ = this;
445 thread_ = new base::Thread(kDevToolsAdbBridgeThreadName); 445 thread_ = new base::Thread(kDevToolsAdbBridgeThreadName);
446 base::Thread::Options options; 446 base::Thread::Options options;
447 options.message_loop_type = base::MessageLoop::TYPE_IO; 447 options.message_loop_type = base::MessageLoop::TYPE_IO;
448 if (!thread_->StartWithOptions(options)) { 448 if (!thread_->StartWithOptions(options)) {
449 delete thread_; 449 delete thread_;
450 thread_ = NULL; 450 thread_ = NULL;
451 } 451 }
452 } 452 }
453 453
454 scoped_refptr<base::MessageLoopProxy> 454 scoped_refptr<base::MessageLoopProxy>
455 AndroidDeviceManager::HandlerThread::message_loop() { 455 AndroidDeviceManager::HandlerThread::message_loop() {
456 return thread_ ? thread_->message_loop_proxy() : NULL; 456 return thread_ ? thread_->message_loop_proxy() : NULL;
457 } 457 }
458 458
459 // static 459 // static
460 void AndroidDeviceManager::HandlerThread::StopThread( 460 void AndroidDeviceManager::HandlerThread::StopThread(
461 base::Thread* thread) { 461 base::Thread* thread) {
462 thread->Stop(); 462 thread->Stop();
463 } 463 }
464 464
465 AndroidDeviceManager::HandlerThread::~HandlerThread() { 465 AndroidDeviceManager::HandlerThread::~HandlerThread() {
466 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 466 DCHECK_CURRENTLY_ON(BrowserThread::UI);
467 instance_ = NULL; 467 instance_ = NULL;
468 if (!thread_) 468 if (!thread_)
469 return; 469 return;
470 // Shut down thread on FILE thread to join into IO. 470 // Shut down thread on FILE thread to join into IO.
471 content::BrowserThread::PostTask( 471 content::BrowserThread::PostTask(
472 content::BrowserThread::FILE, FROM_HERE, 472 content::BrowserThread::FILE, FROM_HERE,
473 base::Bind(&HandlerThread::StopThread, thread_)); 473 base::Bind(&HandlerThread::StopThread, thread_));
474 } 474 }
475 475
476 // static 476 // static
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 it->provider, it->serial); 523 it->provider, it->serial);
524 } else { 524 } else {
525 device = found->second.get(); 525 device = found->second.get();
526 } 526 }
527 response.push_back(device); 527 response.push_back(device);
528 new_devices[it->serial] = device->weak_factory_.GetWeakPtr(); 528 new_devices[it->serial] = device->weak_factory_.GetWeakPtr();
529 } 529 }
530 devices_.swap(new_devices); 530 devices_.swap(new_devices);
531 callback.Run(response); 531 callback.Run(response);
532 } 532 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/devtools/device/android_web_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698