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

Side by Side Diff: third_party/WebKit/Source/platform/WebViewScheduler.cpp

Issue 2109843003: Adds enableVirtualTime and setVirtualTimePolicy To Emulation domain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix layering issue Created 4 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "public/platform/WebViewScheduler.h"
6
7 namespace blink {
8
9 WebViewScheduler::WebViewScheduler()
Sami 2016/07/01 14:46:30 Let's avoid forking WebViewScheduler and WebViewSc
alex clarke (OOO till 29th) 2016/07/01 15:53:23 Done.
10 : m_pendingResourceLoadCount(0)
11 , m_virtualTimePolicy(VirtualTimePolicy::ADVANCE) { }
12
13 WebViewScheduler::~WebViewScheduler() { }
14
15 void WebViewScheduler::incrementPendingResourceLoadCount()
16 {
17 m_pendingResourceLoadCount++;
18
19 if (m_virtualTimePolicy != VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDI NG)
20 return;
21
22 if (m_pendingResourceLoadCount == 1)
23 setAllowVirtualTimeToAdvance(false);
24 }
25
26 void WebViewScheduler::decrementPendingResourceLoadCount()
27 {
28 m_pendingResourceLoadCount--;
29 DCHECK_GE(m_pendingResourceLoadCount, 0);
30
31 if (m_virtualTimePolicy != VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDI NG)
32 return;
33
34 if (m_pendingResourceLoadCount == 0)
35 setAllowVirtualTimeToAdvance(true);
36 }
37
38 void WebViewScheduler::setVirtualTimePolicy(VirtualTimePolicy policy)
39 {
40 m_virtualTimePolicy = policy;
41
42 switch (m_virtualTimePolicy) {
43 case VirtualTimePolicy::ADVANCE:
44 setAllowVirtualTimeToAdvance(true);
45 break;
46
47 case VirtualTimePolicy::PAUSE:
48 setAllowVirtualTimeToAdvance(false);
49 break;
50
51 case VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDING:
52 setAllowVirtualTimeToAdvance(m_pendingResourceLoadCount == 0);
53 break;
54 }
55 }
56
57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698