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 "chrome/browser/budget_service/budget_manager.h" | 7 #include "chrome/browser/budget_service/budget_manager.h" |
8 #include "chrome/browser/budget_service/budget_manager_factory.h" | 8 #include "chrome/browser/budget_service/budget_manager_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 DCHECK(host); | 48 DCHECK(host); |
49 | 49 |
50 // Query the BudgetManager for the budget. | 50 // Query the BudgetManager for the budget. |
51 content::BrowserContext* context = host->GetBrowserContext(); | 51 content::BrowserContext* context = host->GetBrowserContext(); |
52 BudgetManagerFactory::GetForProfile(context)->GetBudget(origin, callback); | 52 BudgetManagerFactory::GetForProfile(context)->GetBudget(origin, callback); |
53 } | 53 } |
54 | 54 |
55 void BudgetServiceImpl::Reserve(const url::Origin& origin, | 55 void BudgetServiceImpl::Reserve(const url::Origin& origin, |
56 blink::mojom::BudgetOperationType operation, | 56 blink::mojom::BudgetOperationType operation, |
57 const ReserveCallback& callback) { | 57 const ReserveCallback& callback) { |
58 // TODO(harkness): Call the BudgetManager::Reserve when it is available. | 58 // The RenderProcessHost should still be alive as long as any connections are |
59 callback.Run(blink::mojom::BudgetServiceErrorType::NONE, false); | 59 // alive, and if the BudgetService mojo connection is down, the |
| 60 // BudgetServiceImpl should have been destroyed. |
| 61 content::RenderProcessHost* host = |
| 62 content::RenderProcessHost::FromID(render_process_id_); |
| 63 DCHECK(host); |
| 64 |
| 65 // Request a reservation from the BudgetManager. |
| 66 content::BrowserContext* context = host->GetBrowserContext(); |
| 67 BudgetManagerFactory::GetForProfile(context)->Reserve(origin, operation, |
| 68 callback); |
60 } | 69 } |
OLD | NEW |