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

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

Issue 2934063002: Always use milliseconds in the Budget API implementation (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « chrome/browser/budget_service/budget_database_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/permissions/permission_manager.h" 10 #include "chrome/browser/permissions/permission_manager.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // By request of the Privacy Team, we only communicate the budget buckets with 62 // By request of the Privacy Team, we only communicate the budget buckets with
63 // the developer when the notification permission has been granted. This is 63 // the developer when the notification permission has been granted. This is
64 // something the impact of which has to be reconsidered when the feature is 64 // something the impact of which has to be reconsidered when the feature is
65 // ready to ship for real. See https://crbug.com/710809 for context. 65 // ready to ship for real. See https://crbug.com/710809 for context.
66 if (permission_manager->GetPermissionStatus( 66 if (permission_manager->GetPermissionStatus(
67 content::PermissionType::NOTIFICATIONS, origin.GetURL(), GURL()) != 67 content::PermissionType::NOTIFICATIONS, origin.GetURL(), GURL()) !=
68 blink::mojom::PermissionStatus::GRANTED) { 68 blink::mojom::PermissionStatus::GRANTED) {
69 blink::mojom::BudgetStatePtr empty_state(blink::mojom::BudgetState::New()); 69 blink::mojom::BudgetStatePtr empty_state(blink::mojom::BudgetState::New());
70 empty_state->budget_at = 0; 70 empty_state->budget_at = 0;
71 empty_state->time = base::Time::Now().ToDoubleT(); 71 empty_state->time =
72 base::Time::Now().ToDoubleT() * base::Time::kMillisecondsPerSecond;
72 73
73 std::vector<blink::mojom::BudgetStatePtr> predictions; 74 std::vector<blink::mojom::BudgetStatePtr> predictions;
74 predictions.push_back(std::move(empty_state)); 75 predictions.push_back(std::move(empty_state));
75 76
76 callback.Run(blink::mojom::BudgetServiceErrorType::NONE, 77 callback.Run(blink::mojom::BudgetServiceErrorType::NONE,
77 std::move(predictions)); 78 std::move(predictions));
78 return; 79 return;
79 } 80 }
80 81
81 // Query the BudgetManager for the budget. 82 // Query the BudgetManager for the budget.
82 BudgetManagerFactory::GetForProfile(profile)->GetBudget(origin, callback); 83 BudgetManagerFactory::GetForProfile(profile)->GetBudget(origin, callback);
83 } 84 }
84 85
85 void BudgetServiceImpl::Reserve(const url::Origin& origin, 86 void BudgetServiceImpl::Reserve(const url::Origin& origin,
86 blink::mojom::BudgetOperationType operation, 87 blink::mojom::BudgetOperationType operation,
87 const ReserveCallback& callback) { 88 const ReserveCallback& callback) {
88 // The RenderProcessHost should still be alive as long as any connections are 89 // The RenderProcessHost should still be alive as long as any connections are
89 // alive, and if the BudgetService mojo connection is down, the 90 // alive, and if the BudgetService mojo connection is down, the
90 // BudgetServiceImpl should have been destroyed. 91 // BudgetServiceImpl should have been destroyed.
91 content::RenderProcessHost* host = 92 content::RenderProcessHost* host =
92 content::RenderProcessHost::FromID(render_process_id_); 93 content::RenderProcessHost::FromID(render_process_id_);
93 DCHECK(host); 94 DCHECK(host);
94 95
95 // Request a reservation from the BudgetManager. 96 // Request a reservation from the BudgetManager.
96 content::BrowserContext* context = host->GetBrowserContext(); 97 content::BrowserContext* context = host->GetBrowserContext();
97 BudgetManagerFactory::GetForProfile(context)->Reserve(origin, operation, 98 BudgetManagerFactory::GetForProfile(context)->Reserve(origin, operation,
98 callback); 99 callback);
99 } 100 }
OLDNEW
« no previous file with comments | « chrome/browser/budget_service/budget_database_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698