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

Side by Side Diff: content/shell/renderer/test_runner/test_runner.cc

Issue 566833002: Update WebTask in chromium c++ style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolved build error Created 6 years, 3 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 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 "content/shell/renderer/test_runner/test_runner.h" 5 #include "content/shell/renderer/test_runner/test_runner.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/shell/common/test_runner/test_preferences.h" 10 #include "content/shell/common/test_runner/test_preferences.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 v8_str->WriteUtf8(chars.get(), length); 64 v8_str->WriteUtf8(chars.get(), length);
65 return WebString::fromUTF8(chars.get()); 65 return WebString::fromUTF8(chars.get());
66 } 66 }
67 67
68 class HostMethodTask : public WebMethodTask<TestRunner> { 68 class HostMethodTask : public WebMethodTask<TestRunner> {
69 public: 69 public:
70 typedef void (TestRunner::*CallbackMethodType)(); 70 typedef void (TestRunner::*CallbackMethodType)();
71 HostMethodTask(TestRunner* object, CallbackMethodType callback) 71 HostMethodTask(TestRunner* object, CallbackMethodType callback)
72 : WebMethodTask<TestRunner>(object), callback_(callback) {} 72 : WebMethodTask<TestRunner>(object), callback_(callback) {}
73 73
74 virtual void runIfValid() OVERRIDE { 74 virtual void RunIfValid() OVERRIDE { (object_->*callback_)(); }
75 (m_object->*callback_)();
76 }
77 75
78 private: 76 private:
79 CallbackMethodType callback_; 77 CallbackMethodType callback_;
80 }; 78 };
81 79
82 } // namespace 80 } // namespace
83 81
84 class InvokeCallbackTask : public WebMethodTask<TestRunner> { 82 class InvokeCallbackTask : public WebMethodTask<TestRunner> {
85 public: 83 public:
86 InvokeCallbackTask(TestRunner* object, v8::Handle<v8::Function> callback) 84 InvokeCallbackTask(TestRunner* object, v8::Handle<v8::Function> callback)
87 : WebMethodTask<TestRunner>(object), 85 : WebMethodTask<TestRunner>(object),
88 callback_(blink::mainThreadIsolate(), callback), 86 callback_(blink::mainThreadIsolate(), callback),
89 argc_(0) {} 87 argc_(0) {}
90 88
91 virtual void runIfValid() OVERRIDE { 89 virtual void RunIfValid() OVERRIDE {
92 v8::Isolate* isolate = blink::mainThreadIsolate(); 90 v8::Isolate* isolate = blink::mainThreadIsolate();
93 v8::HandleScope handle_scope(isolate); 91 v8::HandleScope handle_scope(isolate);
94 WebFrame* frame = m_object->web_view_->mainFrame(); 92 WebFrame* frame = object_->web_view_->mainFrame();
95 93
96 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); 94 v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
97 if (context.IsEmpty()) 95 if (context.IsEmpty())
98 return; 96 return;
99 97
100 v8::Context::Scope context_scope(context); 98 v8::Context::Scope context_scope(context);
101 99
102 scoped_ptr<v8::Handle<v8::Value>[]> local_argv; 100 scoped_ptr<v8::Handle<v8::Value>[]> local_argv;
103 if (argc_) { 101 if (argc_) {
104 local_argv.reset(new v8::Handle<v8::Value>[argc_]); 102 local_argv.reset(new v8::Handle<v8::Value>[argc_]);
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 delete queue_.front(); 1483 delete queue_.front();
1486 queue_.pop_front(); 1484 queue_.pop_front();
1487 if (startedLoad) 1485 if (startedLoad)
1488 return; 1486 return;
1489 } 1487 }
1490 1488
1491 if (!controller_->wait_until_done_ && !controller_->topLoadingFrame()) 1489 if (!controller_->wait_until_done_ && !controller_->topLoadingFrame())
1492 controller_->delegate_->testFinished(); 1490 controller_->delegate_->testFinished();
1493 } 1491 }
1494 1492
1495 void TestRunner::WorkQueue::WorkQueueTask::runIfValid() { 1493 void TestRunner::WorkQueue::WorkQueueTask::RunIfValid() {
1496 m_object->ProcessWork(); 1494 object_->ProcessWork();
1497 } 1495 }
1498 1496
1499 TestRunner::TestRunner(TestInterfaces* interfaces) 1497 TestRunner::TestRunner(TestInterfaces* interfaces)
1500 : test_is_running_(false), 1498 : test_is_running_(false),
1501 close_remaining_windows_(false), 1499 close_remaining_windows_(false),
1502 work_queue_(this), 1500 work_queue_(this),
1503 disable_notify_done_(false), 1501 disable_notify_done_(false),
1504 web_history_item_count_(0), 1502 web_history_item_count_(0),
1505 intercept_post_message_(false), 1503 intercept_post_message_(false),
1506 test_interfaces_(interfaces), 1504 test_interfaces_(interfaces),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 web_history_item_count_ = 0; 1615 web_history_item_count_ = 0;
1618 intercept_post_message_ = false; 1616 intercept_post_message_ = false;
1619 1617
1620 web_permissions_->Reset(); 1618 web_permissions_->Reset();
1621 1619
1622 notification_presenter_->Reset(); 1620 notification_presenter_->Reset();
1623 use_mock_theme_ = true; 1621 use_mock_theme_ = true;
1624 pointer_locked_ = false; 1622 pointer_locked_ = false;
1625 pointer_lock_planned_result_ = PointerLockWillSucceed; 1623 pointer_lock_planned_result_ = PointerLockWillSucceed;
1626 1624
1627 task_list_.revokeAll(); 1625 task_list_.RevokeAll();
1628 work_queue_.Reset(); 1626 work_queue_.Reset();
1629 1627
1630 if (close_remaining_windows_ && delegate_) 1628 if (close_remaining_windows_ && delegate_)
1631 delegate_->closeRemainingWindows(); 1629 delegate_->closeRemainingWindows();
1632 else 1630 else
1633 close_remaining_windows_ = true; 1631 close_remaining_windows_ = true;
1634 } 1632 }
1635 1633
1636 void TestRunner::SetTestIsRunning(bool running) { 1634 void TestRunner::SetTestIsRunning(bool running) {
1637 test_is_running_ = running; 1635 test_is_running_ = running;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 1897
1900 private: 1898 private:
1901 int distance_; 1899 int distance_;
1902 }; 1900 };
1903 1901
1904 void TestRunner::NotifyDone() { 1902 void TestRunner::NotifyDone() {
1905 if (disable_notify_done_) 1903 if (disable_notify_done_)
1906 return; 1904 return;
1907 1905
1908 // Test didn't timeout. Kill the timeout timer. 1906 // Test didn't timeout. Kill the timeout timer.
1909 task_list_.revokeAll(); 1907 task_list_.RevokeAll();
1910 1908
1911 CompleteNotifyDone(); 1909 CompleteNotifyDone();
1912 } 1910 }
1913 1911
1914 void TestRunner::WaitUntilDone() { 1912 void TestRunner::WaitUntilDone() {
1915 wait_until_done_ = true; 1913 wait_until_done_ = true;
1916 } 1914 }
1917 1915
1918 void TestRunner::QueueBackNavigation(int how_far_back) { 1916 void TestRunner::QueueBackNavigation(int how_far_back) {
1919 work_queue_.AddWork(new WorkItemBackForward(-how_far_back)); 1917 work_queue_.AddWork(new WorkItemBackForward(-how_far_back));
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 } 2894 }
2897 2895
2898 void TestRunner::DidLosePointerLockInternal() { 2896 void TestRunner::DidLosePointerLockInternal() {
2899 bool was_locked = pointer_locked_; 2897 bool was_locked = pointer_locked_;
2900 pointer_locked_ = false; 2898 pointer_locked_ = false;
2901 if (was_locked) 2899 if (was_locked)
2902 web_view_->didLosePointerLock(); 2900 web_view_->didLosePointerLock();
2903 } 2901 }
2904 2902
2905 } // namespace content 2903 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | content/shell/renderer/test_runner/web_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698