summaryrefslogtreecommitdiffstats
path: root/components/scheduler/renderer/web_frame_host_scheduler_impl.cc
blob: a8fad7f0c64ae9386ec6725c0a74577e5c7acbc9 (plain)
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
// 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.

#include "components/scheduler/renderer/web_frame_host_scheduler_impl.h"

#include "base/logging.h"
#include "components/scheduler/renderer/web_frame_scheduler_impl.h"

namespace scheduler {

WebFrameHostSchedulerImpl::WebFrameHostSchedulerImpl(
    RendererScheduler* render_scheduler)
    : render_scheduler_(render_scheduler), background_(false) {}

WebFrameHostSchedulerImpl::~WebFrameHostSchedulerImpl() {
  // TODO(alexclarke): Find out why we can't rely on the frame host outliving
  // the frame.
  for (WebFrameSchedulerImpl* frame_scheduler : frame_schedulers_) {
    frame_scheduler->DetachFromFrameHostScheduler();
  }
}

void WebFrameHostSchedulerImpl::setPageInBackground(bool background) {
  background_ = background;
  // TODO(alexclarke): Do something with this flag.
}

blink::WebFrameScheduler* WebFrameHostSchedulerImpl::createFrameScheduler() {
  WebFrameSchedulerImpl* frame_scheduler =
      new WebFrameSchedulerImpl(render_scheduler_, this);
  frame_schedulers_.insert(frame_scheduler);
  return frame_scheduler;
}

void WebFrameHostSchedulerImpl::Unregister(
    WebFrameSchedulerImpl* frame_scheduler) {
  DCHECK(frame_schedulers_.find(frame_scheduler) != frame_schedulers_.end());
  frame_schedulers_.erase(frame_scheduler);
}

}  // namespace scheduler