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

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: Removed Exposed lines and fixed build error. 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()
13 {
14 }
15
16 // static
17 const char* NavigatorBudget::supplementName()
18 {
19 return "NavigatorBudget";
20 }
21
22 // static
23 NavigatorBudget& NavigatorBudget::from(Navigator& navigator)
24 {
25 // Get the unique NavigatorBudget associated with this navigator.
26 NavigatorBudget* navigatorBudget = static_cast<NavigatorBudget*>(Supplement< Navigator>::from(navigator, supplementName()));
27 if (!navigatorBudget) {
28 // If there isn't one already, create it now and associate it.
29 navigatorBudget = new NavigatorBudget();
30 Supplement<Navigator>::provideTo(navigator, supplementName(), navigatorB udget);
31 }
32 return *navigatorBudget;
33 }
34
35 Budget* NavigatorBudget::budget()
36 {
37 if (!m_budget)
38 m_budget = Budget::create();
39 return m_budget.get();
40 }
41
42 // static
43 Budget* NavigatorBudget::budget(Navigator& navigator)
44 {
45 return NavigatorBudget::from(navigator).budget();
46 }
47
48 DEFINE_TRACE(NavigatorBudget)
49 {
50 visitor->trace(m_budget);
51 Supplement<Navigator>::trace(visitor);
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698