1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
// 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 WebFrameScheduler_h
#define WebFrameScheduler_h
#include "wtf/RefPtr.h"
#include <memory>
namespace blink {
class WebTaskRunner;
class WebViewScheduler;
class WebFrameScheduler {
public:
virtual ~WebFrameScheduler() {}
class ActiveConnectionHandle {
public:
ActiveConnectionHandle() {}
virtual ~ActiveConnectionHandle() {}
private:
DISALLOW_COPY_AND_ASSIGN(ActiveConnectionHandle);
};
// The scheduler may throttle tasks associated with offscreen frames.
virtual void setFrameVisible(bool) {}
// Tells the scheduler that the page this frame belongs to supposed to be
// throttled (because it's not been visible for a few seconds).
virtual void setPageThrottled(bool) {}
// Set whether this frame is suspended. Only unthrottledTaskRunner tasks are
// allowed to run on a suspended frame.
virtual void setSuspended(bool) {}
// Set whether this frame is cross origin w.r.t. the top level frame. Cross
// origin frames may use a different scheduling policy from same origin
// frames.
virtual void setCrossOrigin(bool) {}
// Returns the WebTaskRunner for loading tasks.
// WebFrameScheduler owns the returned WebTaskRunner.
virtual RefPtr<WebTaskRunner> loadingTaskRunner() = 0;
// Returns the WebTaskRunner for timer tasks.
// WebFrameScheduler owns the returned WebTaskRunner.
virtual RefPtr<WebTaskRunner> timerTaskRunner() = 0;
// Returns the WebTaskRunner for tasks which should never get throttled.
// This is generally used for executing internal browser tasks which should
// never be throttled. Ideally only tasks whose performance characteristics
// are known should be posted to this task runner; for example user
// JavaScript is discouraged. WebFrameScheduler owns the returned
// WebTaskRunner.
virtual RefPtr<WebTaskRunner> unthrottledTaskRunner() = 0;
// Returns the parent WebViewScheduler.
virtual WebViewScheduler* webViewScheduler() { return nullptr; }
// Tells the scheduler a resource load has started. The scheduler may make
// policy decisions based on this.
virtual void didStartLoading(unsigned long identifier) {}
// Tells the scheduler a resource load has stopped. The scheduler may make
// policy decisions based on this.
virtual void didStopLoading(unsigned long identifier) {}
// Tells the scheduler if we are parsing a document on another thread. This
// tells the scheduler not to advance virtual time if it's using the
// DETERMINISTIC_LOADING policy.
virtual void setDocumentParsingInBackground(bool) {}
// Tells the scheduler that the first meaningful paint has occured for this
// frame.
virtual void onFirstMeaningfulPaint() {}
// Notifies scheduler that this frame has established an active real time
// connection (websocket, webrtc, etc). When connection is closed this handle
// must be destroyed.
virtual std::unique_ptr<ActiveConnectionHandle> onActiveConnectionCreated() {
return nullptr;
};
};
} // namespace blink
#endif // WebFrameScheduler_h
|