OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/budget_service/budget_service_impl.h" | 5 #include "chrome/browser/budget_service/budget_service_impl.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/budget_service/budget_manager.h" | 8 #include "chrome/browser/budget_service/budget_manager.h" |
9 #include "chrome/browser/budget_service/budget_manager_factory.h" | 9 #include "chrome/browser/budget_service/budget_manager_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
13 | 13 |
14 BudgetServiceImpl::BudgetServiceImpl(int render_process_id) | 14 BudgetServiceImpl::BudgetServiceImpl(int render_process_id) |
15 : render_process_id_(render_process_id) {} | 15 : render_process_id_(render_process_id) {} |
16 | 16 |
17 BudgetServiceImpl::~BudgetServiceImpl() = default; | 17 BudgetServiceImpl::~BudgetServiceImpl() = default; |
18 | 18 |
19 // static | 19 // static |
20 void BudgetServiceImpl::Create(int render_process_id, | 20 void BudgetServiceImpl::Create( |
21 blink::mojom::BudgetServiceRequest request) { | 21 int render_process_id, |
| 22 const service_manager::BindSourceInfo& source_info, |
| 23 blink::mojom::BudgetServiceRequest request) { |
22 mojo::MakeStrongBinding( | 24 mojo::MakeStrongBinding( |
23 base::MakeUnique<BudgetServiceImpl>(render_process_id), | 25 base::MakeUnique<BudgetServiceImpl>(render_process_id), |
24 std::move(request)); | 26 std::move(request)); |
25 } | 27 } |
26 | 28 |
27 void BudgetServiceImpl::GetCost(blink::mojom::BudgetOperationType type, | 29 void BudgetServiceImpl::GetCost(blink::mojom::BudgetOperationType type, |
28 const GetCostCallback& callback) { | 30 const GetCostCallback& callback) { |
29 // The RenderProcessHost should still be alive as long as any connections are | 31 // The RenderProcessHost should still be alive as long as any connections are |
30 // alive, and if the BudgetService mojo connection is down, the | 32 // alive, and if the BudgetService mojo connection is down, the |
31 // BudgetServiceImpl should have been destroyed. | 33 // BudgetServiceImpl should have been destroyed. |
(...skipping 29 matching lines...) Expand all Loading... |
61 // BudgetServiceImpl should have been destroyed. | 63 // BudgetServiceImpl should have been destroyed. |
62 content::RenderProcessHost* host = | 64 content::RenderProcessHost* host = |
63 content::RenderProcessHost::FromID(render_process_id_); | 65 content::RenderProcessHost::FromID(render_process_id_); |
64 DCHECK(host); | 66 DCHECK(host); |
65 | 67 |
66 // Request a reservation from the BudgetManager. | 68 // Request a reservation from the BudgetManager. |
67 content::BrowserContext* context = host->GetBrowserContext(); | 69 content::BrowserContext* context = host->GetBrowserContext(); |
68 BudgetManagerFactory::GetForProfile(context)->Reserve(origin, operation, | 70 BudgetManagerFactory::GetForProfile(context)->Reserve(origin, operation, |
69 callback); | 71 callback); |
70 } | 72 } |
OLD | NEW |