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

Side by Side Diff: extensions/browser/api/idle/idle_manager.cc

Issue 2038613003: Revert of ExtensionFunction: don't pass ownership of base::Value by raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/idle/idle_manager.h" 5 #include "extensions/browser/api/idle/idle_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
10 #include "base/stl_util.h" 9 #include "base/stl_util.h"
11 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
12 #include "extensions/browser/api/idle/idle_api_constants.h" 11 #include "extensions/browser/api/idle/idle_api_constants.h"
13 #include "extensions/browser/event_router.h" 12 #include "extensions/browser/event_router.h"
14 #include "extensions/browser/extension_registry.h" 13 #include "extensions/browser/extension_registry.h"
15 #include "extensions/common/api/idle.h" 14 #include "extensions/common/api/idle.h"
16 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
17 16
18 namespace keys = extensions::idle_api_constants; 17 namespace keys = extensions::idle_api_constants;
19 namespace idle = extensions::api::idle; 18 namespace idle = extensions::api::idle;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DCHECK(thread_checker_.CalledOnValidThread()); 173 DCHECK(thread_checker_.CalledOnValidThread());
175 idle_time_provider_->CalculateIdleState(threshold, notify); 174 idle_time_provider_->CalculateIdleState(threshold, notify);
176 } 175 }
177 176
178 void IdleManager::SetThreshold(const std::string& extension_id, int threshold) { 177 void IdleManager::SetThreshold(const std::string& extension_id, int threshold) {
179 DCHECK(thread_checker_.CalledOnValidThread()); 178 DCHECK(thread_checker_.CalledOnValidThread());
180 GetMonitor(extension_id)->threshold = threshold; 179 GetMonitor(extension_id)->threshold = threshold;
181 } 180 }
182 181
183 // static 182 // static
184 std::unique_ptr<base::StringValue> IdleManager::CreateIdleValue( 183 base::StringValue* IdleManager::CreateIdleValue(ui::IdleState idle_state) {
185 ui::IdleState idle_state) {
186 const char* description; 184 const char* description;
187 185
188 if (idle_state == ui::IDLE_STATE_ACTIVE) { 186 if (idle_state == ui::IDLE_STATE_ACTIVE) {
189 description = keys::kStateActive; 187 description = keys::kStateActive;
190 } else if (idle_state == ui::IDLE_STATE_IDLE) { 188 } else if (idle_state == ui::IDLE_STATE_IDLE) {
191 description = keys::kStateIdle; 189 description = keys::kStateIdle;
192 } else { 190 } else {
193 description = keys::kStateLocked; 191 description = keys::kStateLocked;
194 } 192 }
195 193
196 return base::MakeUnique<base::StringValue>(description); 194 return new base::StringValue(description);
197 } 195 }
198 196
199 void IdleManager::SetEventDelegateForTest( 197 void IdleManager::SetEventDelegateForTest(
200 std::unique_ptr<EventDelegate> event_delegate) { 198 std::unique_ptr<EventDelegate> event_delegate) {
201 DCHECK(thread_checker_.CalledOnValidThread()); 199 DCHECK(thread_checker_.CalledOnValidThread());
202 event_delegate_ = std::move(event_delegate); 200 event_delegate_ = std::move(event_delegate);
203 } 201 }
204 202
205 void IdleManager::SetIdleTimeProviderForTest( 203 void IdleManager::SetIdleTimeProviderForTest(
206 std::unique_ptr<IdleTimeProvider> idle_time_provider) { 204 std::unique_ptr<IdleTimeProvider> idle_time_provider) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 event_delegate_->OnStateChanged(it->first, new_state); 254 event_delegate_->OnStateChanged(it->first, new_state);
257 monitor.last_state = new_state; 255 monitor.last_state = new_state;
258 listener_count += monitor.listeners; 256 listener_count += monitor.listeners;
259 } 257 }
260 258
261 if (listener_count == 0) 259 if (listener_count == 0)
262 StopPolling(); 260 StopPolling();
263 } 261 }
264 262
265 } // namespace extensions 263 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/idle/idle_manager.h ('k') | extensions/browser/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698