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

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

Issue 2273743002: Framework and tests for WorkerNavigatorBudget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_service
Patch Set: Changed formatting of javascript in html files 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/WorkerNavigatorBudget.h"
6
7 #include "core/workers/WorkerNavigator.h"
8 #include "modules/budget/BudgetService.h"
9
10 namespace blink {
11
12 WorkerNavigatorBudget::WorkerNavigatorBudget()
13 {
14 }
15
16 // static
17 const char* WorkerNavigatorBudget::supplementName()
18 {
19 return "WorkerNavigatorBudget";
20 }
21
22 // static
23 WorkerNavigatorBudget& WorkerNavigatorBudget::from(WorkerNavigator& workerNaviga tor)
24 {
25 // Get the unique WorkerNavigatorBudget associated with this workerNavigator .
26 WorkerNavigatorBudget* workerNavigatorBudget = static_cast<WorkerNavigatorBu dget*>(Supplement<WorkerNavigator>::from(workerNavigator, supplementName()));
27 if (!workerNavigatorBudget) {
28 // If there isn't one already, create it now and associate it.
29 workerNavigatorBudget = new WorkerNavigatorBudget();
30 Supplement<WorkerNavigator>::provideTo(workerNavigator, supplementName() , workerNavigatorBudget);
31 }
32 return *workerNavigatorBudget;
33 }
34
35 BudgetService* WorkerNavigatorBudget::budget()
36 {
37 if (!m_budget)
38 m_budget = BudgetService::create();
39 return m_budget.get();
40 }
41
42 // static
43 BudgetService* WorkerNavigatorBudget::budget(WorkerNavigator& workerNavigator)
44 {
45 return WorkerNavigatorBudget::from(workerNavigator).budget();
46 }
47
48 DEFINE_TRACE(WorkerNavigatorBudget)
49 {
50 visitor->trace(m_budget);
51 Supplement<WorkerNavigator>::trace(visitor);
52 }
53
54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698