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

Side by Side Diff: chrome/browser/budget_service/budget_service_impl.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 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
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"
11 #include "mojo/public/cpp/bindings/strong_binding.h"
12
13 BudgetServiceImpl::BudgetServiceImpl(int render_process_id)
14 : render_process_id_(render_process_id) {}
15
16 BudgetServiceImpl::~BudgetServiceImpl() = default;
11 17
12 // static 18 // static
13 void BudgetServiceImpl::Create(int render_process_id, 19 void BudgetServiceImpl::Create(int render_process_id,
14 blink::mojom::BudgetServiceRequest request) { 20 blink::mojom::BudgetServiceRequest request) {
15 new BudgetServiceImpl(render_process_id, std::move(request)); 21 mojo::MakeStrongBinding(
22 base::MakeUnique<BudgetServiceImpl>(render_process_id),
23 std::move(request));
16 } 24 }
17 25
18 BudgetServiceImpl::BudgetServiceImpl(int render_process_id,
19 blink::mojom::BudgetServiceRequest request)
20 : render_process_id_(render_process_id),
21 binding_(this, std::move(request)) {}
22
23 BudgetServiceImpl::~BudgetServiceImpl() = default;
24
25 void BudgetServiceImpl::GetCost(blink::mojom::BudgetOperationType type, 26 void BudgetServiceImpl::GetCost(blink::mojom::BudgetOperationType type,
26 const GetCostCallback& callback) { 27 const GetCostCallback& callback) {
27 // The RenderProcessHost should still be alive as long as any connections are 28 // The RenderProcessHost should still be alive as long as any connections are
28 // alive, and if the BudgetService mojo connection is down, the 29 // alive, and if the BudgetService mojo connection is down, the
29 // BudgetServiceImpl should have been destroyed. 30 // BudgetServiceImpl should have been destroyed.
30 content::RenderProcessHost* host = 31 content::RenderProcessHost* host =
31 content::RenderProcessHost::FromID(render_process_id_); 32 content::RenderProcessHost::FromID(render_process_id_);
32 DCHECK(host); 33 DCHECK(host);
33 34
34 // Query the BudgetManager for the cost and return it. 35 // Query the BudgetManager for the cost and return it.
(...skipping 15 matching lines...) Expand all
50 content::BrowserContext* context = host->GetBrowserContext(); 51 content::BrowserContext* context = host->GetBrowserContext();
51 BudgetManagerFactory::GetForProfile(context)->GetBudget(origin, callback); 52 BudgetManagerFactory::GetForProfile(context)->GetBudget(origin, callback);
52 } 53 }
53 54
54 void BudgetServiceImpl::Reserve(const url::Origin& origin, 55 void BudgetServiceImpl::Reserve(const url::Origin& origin,
55 blink::mojom::BudgetOperationType operation, 56 blink::mojom::BudgetOperationType operation,
56 const ReserveCallback& callback) { 57 const ReserveCallback& callback) {
57 // TODO(harkness): Call the BudgetManager::Reserve when it is available. 58 // TODO(harkness): Call the BudgetManager::Reserve when it is available.
58 callback.Run(blink::mojom::BudgetServiceErrorType::NONE, false); 59 callback.Run(blink::mojom::BudgetServiceErrorType::NONE, false);
59 } 60 }
OLDNEW
« no previous file with comments | « chrome/browser/budget_service/budget_service_impl.h ('k') | chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698