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

Side by Side Diff: third_party/WebKit/Source/modules/budget/NavigatorBudget.cpp

Issue 2110833002: Basic framework for Budget API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated to (almost) match the spec Created 4 years, 4 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 "modules/budget/NavigatorBudget.h"
6
7 #include "core/frame/Navigator.h"
8 #include "modules/budget/Budget.h"
9
10 namespace blink {
11
12 NavigatorBudget::NavigatorBudget(Navigator* navigator)
13 : m_navigator(navigator)
14 {
15 }
16
17 NavigatorBudget::~NavigatorBudget()
18 {
19 }
20
21 // static
22 const char* NavigatorBudget::supplementName()
23 {
24 return "NavigatorBudget";
25 }
26
27 // static
28 NavigatorBudget& NavigatorBudget::from(Navigator& navigator)
29 {
30 // Get the unique NavigatorBudget associated with this navigator.
31 NavigatorBudget* navigatorBudget = static_cast<NavigatorBudget*>(Supplement< Navigator>::from(navigator, supplementName()));
32 if (!navigatorBudget) {
33 // If there has not already been a NavigatorBudget created for
34 // this navigator, create one now and associate it.
Peter Beverloo 2016/08/03 13:25:55 nit: the comment on line 33/34 doesn't really add
harkness 2016/08/04 14:18:23 It's not a huge value, but I do think it makes the
35 navigatorBudget = new NavigatorBudget(&navigator);
36 Supplement<Navigator>::provideTo(navigator, supplementName(), navigatorB udget);
37 }
38 return *navigatorBudget;
39 }
40
41 // static
42 Budget* NavigatorBudget::budget()
43 {
44 if (!m_budget)
45 m_budget = Budget::create(m_navigator);
46 return m_budget.get();
47 }
48
49 Budget* NavigatorBudget::budget(Navigator& navigator)
50 {
51 return NavigatorBudget::from(navigator).budget();
52 }
53
54 DEFINE_TRACE(NavigatorBudget)
55 {
56 visitor->trace(m_navigator);
57 visitor->trace(m_budget);
58 Supplement<Navigator>::trace(visitor);
59 }
60
61 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698