| 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 #ifndef CHROME_BROWSER_BUDGET_SERVICE_BUDGET_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_BUDGET_SERVICE_BUDGET_SERVICE_IMPL_H_ |
| 6 #define CHROME_BROWSER_BUDGET_SERVICE_BUDGET_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_BUDGET_SERVICE_BUDGET_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 10 #include "third_party/WebKit/public/platform/modules/budget_service/budget_servi
ce.mojom.h" | 9 #include "third_party/WebKit/public/platform/modules/budget_service/budget_servi
ce.mojom.h" |
| 11 | 10 |
| 12 // Implementation of the BudgetService Mojo service provided by the browser | 11 // Implementation of the BudgetService Mojo service provided by the browser |
| 13 // layer. It is responsible for dispatching budget requests to the | 12 // layer. It is responsible for dispatching budget requests to the |
| 14 // BudgetManager. | 13 // BudgetManager. |
| 15 class BudgetServiceImpl : public blink::mojom::BudgetService { | 14 class BudgetServiceImpl : public blink::mojom::BudgetService { |
| 16 public: | 15 public: |
| 16 explicit BudgetServiceImpl(int render_process_id); |
| 17 ~BudgetServiceImpl() override; |
| 18 |
| 17 static void Create(int render_process_id, | 19 static void Create(int render_process_id, |
| 18 blink::mojom::BudgetServiceRequest request); | 20 blink::mojom::BudgetServiceRequest request); |
| 19 | 21 |
| 20 // blink::mojom::BudgetService implementation. | 22 // blink::mojom::BudgetService implementation. |
| 21 void GetCost(blink::mojom::BudgetOperationType operation, | 23 void GetCost(blink::mojom::BudgetOperationType operation, |
| 22 const GetCostCallback& callback) override; | 24 const GetCostCallback& callback) override; |
| 23 void GetBudget(const url::Origin& origin, | 25 void GetBudget(const url::Origin& origin, |
| 24 const GetBudgetCallback& callback) override; | 26 const GetBudgetCallback& callback) override; |
| 25 void Reserve(const url::Origin& origin, | 27 void Reserve(const url::Origin& origin, |
| 26 blink::mojom::BudgetOperationType operation, | 28 blink::mojom::BudgetOperationType operation, |
| 27 const ReserveCallback& callback) override; | 29 const ReserveCallback& callback) override; |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 BudgetServiceImpl(int render_process_id, | |
| 31 blink::mojom::BudgetServiceRequest request); | |
| 32 ~BudgetServiceImpl() override; | |
| 33 | |
| 34 // Render process ID is used to get the browser context. | 32 // Render process ID is used to get the browser context. |
| 35 int render_process_id_; | 33 int render_process_id_; |
| 36 | 34 |
| 37 // The lifetime of the mojo service is tied to the lifetime of the connection. | |
| 38 mojo::StrongBinding<blink::mojom::BudgetService> binding_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(BudgetServiceImpl); | 35 DISALLOW_COPY_AND_ASSIGN(BudgetServiceImpl); |
| 41 }; | 36 }; |
| 42 | 37 |
| 43 #endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_SERVICE_IMPL_H_ | 38 #endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_SERVICE_IMPL_H_ |
| OLD | NEW |