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

Side by Side Diff: chrome/browser/ui/test/test_browser_dialog.cc

Issue 2824363002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/ui (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/test/test_browser_dialog.h" 5 #include "chrome/browser/ui/test/test_browser_dialog.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/test/gtest_util.h" 10 #include "base/test/gtest_util.h"
(...skipping 24 matching lines...) Expand all
35 // Helper to break out of the nested run loop that runs a test dialog. 35 // Helper to break out of the nested run loop that runs a test dialog.
36 class WidgetCloser : public views::WidgetObserver { 36 class WidgetCloser : public views::WidgetObserver {
37 public: 37 public:
38 WidgetCloser(views::Widget* widget, DialogAction action) 38 WidgetCloser(views::Widget* widget, DialogAction action)
39 : widget_(widget), weak_ptr_factory_(this) { 39 : widget_(widget), weak_ptr_factory_(this) {
40 widget->AddObserver(this); 40 widget->AddObserver(this);
41 if (action == DialogAction::INTERACTIVE) 41 if (action == DialogAction::INTERACTIVE)
42 return; 42 return;
43 43
44 base::ThreadTaskRunnerHandle::Get()->PostTask( 44 base::ThreadTaskRunnerHandle::Get()->PostTask(
45 FROM_HERE, 45 FROM_HERE, base::BindOnce(&WidgetCloser::CloseNow,
46 base::Bind(&WidgetCloser::CloseNow, weak_ptr_factory_.GetWeakPtr())); 46 weak_ptr_factory_.GetWeakPtr()));
47 } 47 }
48 48
49 // WidgetObserver: 49 // WidgetObserver:
50 void OnWidgetDestroyed(views::Widget* widget) override { 50 void OnWidgetDestroyed(views::Widget* widget) override {
51 widget_->RemoveObserver(this); 51 widget_->RemoveObserver(this);
52 widget_ = nullptr; 52 widget_ = nullptr;
53 base::MessageLoop::current()->QuitNow(); 53 base::MessageLoop::current()->QuitNow();
54 } 54 }
55 55
56 private: 56 private:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ASSERT_EQ(1u, added.size()); 125 ASSERT_EQ(1u, added.size());
126 126
127 const DialogAction action = base::CommandLine::ForCurrentProcess()->HasSwitch( 127 const DialogAction action = base::CommandLine::ForCurrentProcess()->HasSwitch(
128 internal::kInteractiveSwitch) 128 internal::kInteractiveSwitch)
129 ? DialogAction::INTERACTIVE 129 ? DialogAction::INTERACTIVE
130 : DialogAction::CLOSE_NOW; 130 : DialogAction::CLOSE_NOW;
131 131
132 WidgetCloser closer(added[0], action); 132 WidgetCloser closer(added[0], action);
133 ::test::RunTestInteractively(); 133 ::test::RunTestInteractively();
134 } 134 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/hover_tab_selector.cc ('k') | chrome/browser/ui/toolbar/toolbar_actions_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698