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

Side by Side Diff: chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc

Issue 1395103003: Don't use base::MessageLoop::{Quit,QuitClosure} in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 void TabChangedAt(content::WebContents* contents, 431 void TabChangedAt(content::WebContents* contents,
432 int index, 432 int index,
433 TabChangeType change_type) override { 433 TabChangeType change_type) override {
434 const TabMediaState media_state = 434 const TabMediaState media_state =
435 chrome::GetTabMediaStateForContents(contents); 435 chrome::GetTabMediaStateForContents(contents);
436 const bool has_changed = media_state != last_media_state_; 436 const bool has_changed = media_state != last_media_state_;
437 last_media_state_ = media_state; 437 last_media_state_ = media_state;
438 if (has_changed) { 438 if (has_changed) {
439 base::ThreadTaskRunnerHandle::Get()->PostTask( 439 base::ThreadTaskRunnerHandle::Get()->PostTask(
440 FROM_HERE, base::MessageLoop::QuitClosure()); 440 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
441 } 441 }
442 } 442 }
443 443
444 private: 444 private:
445 TabMediaState last_media_state_; 445 TabMediaState last_media_state_;
446 }; 446 };
447 447
448 // Run the browser until the indicator turns on. 448 // Run the browser until the indicator turns on.
449 IndicatorChangeObserver observer(browser()); 449 IndicatorChangeObserver observer(browser());
450 browser()->tab_strip_model()->AddObserver(&observer); 450 browser()->tab_strip_model()->AddObserver(&observer);
451 const base::TimeTicks start_time = base::TimeTicks::Now(); 451 const base::TimeTicks start_time = base::TimeTicks::Now();
452 while (observer.last_media_state() != TAB_MEDIA_STATE_CAPTURING) { 452 while (observer.last_media_state() != TAB_MEDIA_STATE_CAPTURING) {
453 if (base::TimeTicks::Now() - start_time > 453 if (base::TimeTicks::Now() - start_time >
454 base::TimeDelta::FromSeconds(10)) { 454 base::TimeDelta::FromSeconds(10)) {
455 EXPECT_EQ(TAB_MEDIA_STATE_CAPTURING, observer.last_media_state()); 455 EXPECT_EQ(TAB_MEDIA_STATE_CAPTURING, observer.last_media_state());
456 browser()->tab_strip_model()->RemoveObserver(&observer); 456 browser()->tab_strip_model()->RemoveObserver(&observer);
457 return; 457 return;
458 } 458 }
459 content::RunMessageLoop(); 459 content::RunMessageLoop();
460 } 460 }
461 browser()->tab_strip_model()->RemoveObserver(&observer); 461 browser()->tab_strip_model()->RemoveObserver(&observer);
462 } 462 }
463 463
464 } // namespace 464 } // namespace
465 465
466 } // namespace extensions 466 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/notifications/notifications_apitest.cc ('k') | chrome/browser/extensions/api/tabs/tabs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698