blob: 37eb20dfc945b1dc57b5dfa7a8d4db98410db2fd [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WebViewScheduler_h
#define WebViewScheduler_h
#include "WebCommon.h"
#include "public/platform/BlameContext.h"
#include <memory>
namespace blink {
class WebFrameScheduler;
class BLINK_PLATFORM_EXPORT WebViewScheduler {
public:
virtual ~WebViewScheduler() { }
// The scheduler may throttle tasks associated with background pages.
virtual void setPageVisible(bool) = 0;
// Creates a new WebFrameScheduler. The caller is responsible for deleting
// it. All tasks executed by the frame scheduler will be attributed to
// |BlameContext|.
virtual std::unique_ptr<WebFrameScheduler> createFrameScheduler(BlameContext*) = 0;
// Instructs this WebViewScheduler to use virtual time. When virtual time is enabled
// the system doesn't actually sleep for the delays between tasks before executing
// them. E.g: A-E are delayed tasks
//
// | A B C D E (normal)
// |-----------------------------> time
//
// |ABCDE (virtual time)
// |-----------------------------> time
virtual void enableVirtualTime() = 0;
// Returns true if virtual time is currently allowed to advance.
virtual bool virtualTimeAllowedToAdvance() const = 0;
enum class VirtualTimePolicy {
// In this policy virtual time is allowed to advance. If the blink scheduler runs out of
// immediate work, the virtual timebase will be incremented so that the next sceduled
// timer may fire. NOTE Tasks will be run in time order (as usual).
ADVANCE,
// In this policy virtual time is not allowed to advance. Delayed tasks posted to
// WebTaskRunners owned by any child WebFrameSchedulers will be paused, unless their
// scheduled run time is less than or equal to the current virtual time. Note non-delayed
// tasks will run as normal.
PAUSE,
// In this policy virtual time is allowed to advance unless there are pending network
// fetches associated any child WebFrameScheduler.
PAUSE_IF_NETWORK_FETCHES_PENDING
};
// Sets the virtual time policy, which is applied imemdiatly to all child WebFrameSchedulers.
virtual void setVirtualTimePolicy(VirtualTimePolicy) = 0;
};
} // namespace blink
#endif // WebViewScheduler