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

Side by Side Diff: components/test_runner/mock_color_chooser.cc

Issue 1821923003: Extract WebFrameClient implementation out of WebTestProxyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 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
« no previous file with comments | « components/test_runner/mock_color_chooser.h ('k') | components/test_runner/test_common.h » ('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 "components/test_runner/mock_color_chooser.h" 5 #include "components/test_runner/mock_color_chooser.h"
6 6
7 #include "components/test_runner/test_runner.h"
7 #include "components/test_runner/web_test_delegate.h" 8 #include "components/test_runner/web_test_delegate.h"
8 #include "components/test_runner/web_test_proxy.h" 9 #include "components/test_runner/web_test_proxy.h"
9 10
10 namespace test_runner { 11 namespace test_runner {
11 12
12 namespace { 13 namespace {
13 class HostMethodTask : public WebMethodTask<MockColorChooser> { 14 class HostMethodTask : public WebMethodTask<MockColorChooser> {
14 public: 15 public:
15 typedef void (MockColorChooser::*CallbackMethodType)(); 16 typedef void (MockColorChooser::*CallbackMethodType)();
16 HostMethodTask(MockColorChooser* object, CallbackMethodType callback) 17 HostMethodTask(MockColorChooser* object, CallbackMethodType callback)
17 : WebMethodTask<MockColorChooser>(object), 18 : WebMethodTask<MockColorChooser>(object),
18 callback_(callback) {} 19 callback_(callback) {}
19 20
20 void RunIfValid() override { (object_->*callback_)(); } 21 void RunIfValid() override { (object_->*callback_)(); }
21 22
22 private: 23 private:
23 CallbackMethodType callback_; 24 CallbackMethodType callback_;
24 }; 25 };
25 26
26 } // namespace 27 } // namespace
27 28
28 MockColorChooser::MockColorChooser(blink::WebColorChooserClient* client, 29 MockColorChooser::MockColorChooser(blink::WebColorChooserClient* client,
29 WebTestDelegate* delegate, 30 WebTestDelegate* delegate,
30 WebTestProxyBase* proxy) 31 TestRunner* test_runner)
31 : client_(client), 32 : client_(client), delegate_(delegate), test_runner_(test_runner) {
32 delegate_(delegate), 33 test_runner_->DidOpenChooser();
33 proxy_(proxy) {
34 proxy_->DidOpenChooser();
35 } 34 }
36 35
37 MockColorChooser::~MockColorChooser() { 36 MockColorChooser::~MockColorChooser() {
38 proxy_->DidCloseChooser(); 37 test_runner_->DidCloseChooser();
39 } 38 }
40 39
41 void MockColorChooser::setSelectedColor(const blink::WebColor color) {} 40 void MockColorChooser::setSelectedColor(const blink::WebColor color) {}
42 41
43 void MockColorChooser::endChooser() { 42 void MockColorChooser::endChooser() {
43 DCHECK(client_);
44 DCHECK(delegate_);
44 delegate_->PostDelayedTask( 45 delegate_->PostDelayedTask(
45 new HostMethodTask(this, &MockColorChooser::InvokeDidEndChooser), 0); 46 new HostMethodTask(this, &MockColorChooser::InvokeDidEndChooser), 0);
47 delegate_ = nullptr;
46 } 48 }
47 49
48 void MockColorChooser::InvokeDidEndChooser() { 50 void MockColorChooser::InvokeDidEndChooser() {
49 client_->didEndChooser(); 51 client_->didEndChooser();
52 client_ = nullptr;
kochi 2016/03/31 08:14:34 I'm seeing this line is causing a use-after-free.
50 } 53 }
51 54
52 } // namespace test_runner 55 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/mock_color_chooser.h ('k') | components/test_runner/test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698