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

Side by Side Diff: gpu/command_buffer/service/sync_point_manager.cc

Issue 1859703002: convert //gpu to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 4 years, 8 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 "gpu/command_buffer/service/sync_point_manager.h" 5 #include "gpu/command_buffer/service/sync_point_manager.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <climits> 11 #include <climits>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/ptr_util.h"
17 #include "base/rand_util.h" 18 #include "base/rand_util.h"
18 #include "base/sequence_checker.h" 19 #include "base/sequence_checker.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
20 21
21 namespace gpu { 22 namespace gpu {
22 23
23 namespace { 24 namespace {
24 25
25 void RunOnThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner, 26 void RunOnThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
26 const base::Closure& callback) { 27 const base::Closure& callback) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 SyncPointManager::SyncPointManager(bool allow_threaded_wait) { 364 SyncPointManager::SyncPointManager(bool allow_threaded_wait) {
364 global_order_num_.GetNext(); 365 global_order_num_.GetNext();
365 } 366 }
366 367
367 SyncPointManager::~SyncPointManager() { 368 SyncPointManager::~SyncPointManager() {
368 for (const ClientMap& client_map : client_maps_) { 369 for (const ClientMap& client_map : client_maps_) {
369 DCHECK(client_map.empty()); 370 DCHECK(client_map.empty());
370 } 371 }
371 } 372 }
372 373
373 scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClient( 374 std::unique_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClient(
374 scoped_refptr<SyncPointOrderData> order_data, 375 scoped_refptr<SyncPointOrderData> order_data,
375 CommandBufferNamespace namespace_id, 376 CommandBufferNamespace namespace_id,
376 CommandBufferId client_id) { 377 CommandBufferId client_id) {
377 DCHECK_GE(namespace_id, 0); 378 DCHECK_GE(namespace_id, 0);
378 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); 379 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_));
379 base::AutoLock auto_lock(client_maps_lock_); 380 base::AutoLock auto_lock(client_maps_lock_);
380 381
381 ClientMap& client_map = client_maps_[namespace_id]; 382 ClientMap& client_map = client_maps_[namespace_id];
382 std::pair<ClientMap::iterator, bool> result = client_map.insert( 383 std::pair<ClientMap::iterator, bool> result = client_map.insert(
383 std::make_pair(client_id, new SyncPointClient(this, order_data, 384 std::make_pair(client_id, new SyncPointClient(this, order_data,
384 namespace_id, client_id))); 385 namespace_id, client_id)));
385 DCHECK(result.second); 386 DCHECK(result.second);
386 387
387 return make_scoped_ptr(result.first->second); 388 return base::WrapUnique(result.first->second);
388 } 389 }
389 390
390 scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClientWaiter() { 391 std::unique_ptr<SyncPointClient>
391 return make_scoped_ptr(new SyncPointClient); 392 SyncPointManager::CreateSyncPointClientWaiter() {
393 return base::WrapUnique(new SyncPointClient);
392 } 394 }
393 395
394 scoped_refptr<SyncPointClientState> SyncPointManager::GetSyncPointClientState( 396 scoped_refptr<SyncPointClientState> SyncPointManager::GetSyncPointClientState(
395 CommandBufferNamespace namespace_id, 397 CommandBufferNamespace namespace_id,
396 CommandBufferId client_id) { 398 CommandBufferId client_id) {
397 if (namespace_id >= 0) { 399 if (namespace_id >= 0) {
398 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); 400 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_));
399 base::AutoLock auto_lock(client_maps_lock_); 401 base::AutoLock auto_lock(client_maps_lock_);
400 ClientMap& client_map = client_maps_[namespace_id]; 402 ClientMap& client_map = client_maps_[namespace_id];
401 ClientMap::iterator it = client_map.find(client_id); 403 ClientMap::iterator it = client_map.find(client_id);
(...skipping 15 matching lines...) Expand all
417 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); 419 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_));
418 420
419 base::AutoLock auto_lock(client_maps_lock_); 421 base::AutoLock auto_lock(client_maps_lock_);
420 ClientMap& client_map = client_maps_[namespace_id]; 422 ClientMap& client_map = client_maps_[namespace_id];
421 ClientMap::iterator it = client_map.find(client_id); 423 ClientMap::iterator it = client_map.find(client_id);
422 DCHECK(it != client_map.end()); 424 DCHECK(it != client_map.end());
423 client_map.erase(it); 425 client_map.erase(it);
424 } 426 }
425 427
426 } // namespace gpu 428 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/sync_point_manager.h ('k') | gpu/command_buffer/service/sync_point_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698