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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 671663002: Standardize usage of virtual/override/final in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/content_browser_test.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 (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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 public WebContentsObserver { 58 public WebContentsObserver {
59 public: 59 public:
60 explicit DOMOperationObserver(RenderViewHost* rvh) 60 explicit DOMOperationObserver(RenderViewHost* rvh)
61 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)), 61 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)),
62 did_respond_(false) { 62 did_respond_(false) {
63 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, 63 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE,
64 Source<WebContents>(web_contents())); 64 Source<WebContents>(web_contents()));
65 message_loop_runner_ = new MessageLoopRunner; 65 message_loop_runner_ = new MessageLoopRunner;
66 } 66 }
67 67
68 virtual void Observe(int type, 68 void Observe(int type,
69 const NotificationSource& source, 69 const NotificationSource& source,
70 const NotificationDetails& details) override { 70 const NotificationDetails& details) override {
71 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE); 71 DCHECK(type == NOTIFICATION_DOM_OPERATION_RESPONSE);
72 Details<DomOperationNotificationDetails> dom_op_details(details); 72 Details<DomOperationNotificationDetails> dom_op_details(details);
73 response_ = dom_op_details->json; 73 response_ = dom_op_details->json;
74 did_respond_ = true; 74 did_respond_ = true;
75 message_loop_runner_->Quit(); 75 message_loop_runner_->Quit();
76 } 76 }
77 77
78 // Overridden from WebContentsObserver: 78 // Overridden from WebContentsObserver:
79 virtual void RenderProcessGone(base::TerminationStatus status) override { 79 void RenderProcessGone(base::TerminationStatus status) override {
80 message_loop_runner_->Quit(); 80 message_loop_runner_->Quit();
81 } 81 }
82 82
83 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT { 83 bool WaitAndGetResponse(std::string* response) WARN_UNUSED_RESULT {
84 message_loop_runner_->Run(); 84 message_loop_runner_->Run();
85 *response = response_; 85 *response = response_;
86 return did_respond_; 86 return did_respond_;
87 } 87 }
88 88
89 private: 89 private:
90 NotificationRegistrar registrar_; 90 NotificationRegistrar registrar_;
91 std::string response_; 91 std::string response_;
92 bool did_respond_; 92 bool did_respond_;
93 scoped_refptr<MessageLoopRunner> message_loop_runner_; 93 scoped_refptr<MessageLoopRunner> message_loop_runner_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(DOMOperationObserver); 95 DISALLOW_COPY_AND_ASSIGN(DOMOperationObserver);
96 }; 96 };
97 97
98 class InterstitialObserver : public content::WebContentsObserver { 98 class InterstitialObserver : public content::WebContentsObserver {
99 public: 99 public:
100 InterstitialObserver(content::WebContents* web_contents, 100 InterstitialObserver(content::WebContents* web_contents,
101 const base::Closure& attach_callback, 101 const base::Closure& attach_callback,
102 const base::Closure& detach_callback) 102 const base::Closure& detach_callback)
103 : WebContentsObserver(web_contents), 103 : WebContentsObserver(web_contents),
104 attach_callback_(attach_callback), 104 attach_callback_(attach_callback),
105 detach_callback_(detach_callback) { 105 detach_callback_(detach_callback) {
106 } 106 }
107 virtual ~InterstitialObserver() {} 107 ~InterstitialObserver() override {}
108 108
109 // WebContentsObserver methods: 109 // WebContentsObserver methods:
110 virtual void DidAttachInterstitialPage() override { 110 void DidAttachInterstitialPage() override { attach_callback_.Run(); }
111 attach_callback_.Run(); 111 void DidDetachInterstitialPage() override { detach_callback_.Run(); }
112 }
113 virtual void DidDetachInterstitialPage() override {
114 detach_callback_.Run();
115 }
116 112
117 private: 113 private:
118 base::Closure attach_callback_; 114 base::Closure attach_callback_;
119 base::Closure detach_callback_; 115 base::Closure detach_callback_;
120 116
121 DISALLOW_COPY_AND_ASSIGN(InterstitialObserver); 117 DISALLOW_COPY_AND_ASSIGN(InterstitialObserver);
122 }; 118 };
123 119
124 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute. 120 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute.
125 bool ExecuteScriptHelper( 121 bool ExecuteScriptHelper(
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 820 }
825 // The queue should not be empty, unless we were quit because of a timeout. 821 // The queue should not be empty, unless we were quit because of a timeout.
826 if (message_queue_.empty()) 822 if (message_queue_.empty())
827 return false; 823 return false;
828 *message = message_queue_.front(); 824 *message = message_queue_.front();
829 message_queue_.pop(); 825 message_queue_.pop();
830 return true; 826 return true;
831 } 827 }
832 828
833 } // namespace content 829 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/content_browser_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698