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

Side by Side Diff: content/browser/device_sensors/data_fetcher_shared_memory_base.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/device_sensors/data_fetcher_shared_memory_base.h" 5 #include "content/browser/device_sensors/data_fetcher_shared_memory_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void RemoveConsumer(ConsumerType consumer_type); 49 void RemoveConsumer(ConsumerType consumer_type);
50 50
51 unsigned GetConsumersBitmask() const { return consumers_bitmask_; } 51 unsigned GetConsumersBitmask() const { return consumers_bitmask_; }
52 bool IsTimerRunning() const { return timer_ ? timer_->IsRunning() : false; } 52 bool IsTimerRunning() const { return timer_ ? timer_->IsRunning() : false; }
53 53
54 private: 54 private:
55 void DoPoll(); 55 void DoPoll();
56 56
57 unsigned consumers_bitmask_; 57 unsigned consumers_bitmask_;
58 DataFetcherSharedMemoryBase* fetcher_; 58 DataFetcherSharedMemoryBase* fetcher_;
59 scoped_ptr<base::RepeatingTimer> timer_; 59 std::unique_ptr<base::RepeatingTimer> timer_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(PollingThread); 61 DISALLOW_COPY_AND_ASSIGN(PollingThread);
62 }; 62 };
63 63
64 // --- PollingThread methods 64 // --- PollingThread methods
65 65
66 DataFetcherSharedMemoryBase::PollingThread::PollingThread( 66 DataFetcherSharedMemoryBase::PollingThread::PollingThread(
67 const char* name, DataFetcherSharedMemoryBase* fetcher) 67 const char* name, DataFetcherSharedMemoryBase* fetcher)
68 : base::Thread(name), 68 : base::Thread(name),
69 consumers_bitmask_(0), 69 consumers_bitmask_(0),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 base::SharedMemory* DataFetcherSharedMemoryBase::GetSharedMemory( 219 base::SharedMemory* DataFetcherSharedMemoryBase::GetSharedMemory(
220 ConsumerType consumer_type) { 220 ConsumerType consumer_type) {
221 SharedMemoryMap::const_iterator it = shared_memory_map_.find(consumer_type); 221 SharedMemoryMap::const_iterator it = shared_memory_map_.find(consumer_type);
222 if (it != shared_memory_map_.end()) 222 if (it != shared_memory_map_.end())
223 return it->second; 223 return it->second;
224 224
225 size_t buffer_size = GetConsumerSharedMemoryBufferSize(consumer_type); 225 size_t buffer_size = GetConsumerSharedMemoryBufferSize(consumer_type);
226 if (buffer_size == 0) 226 if (buffer_size == 0)
227 return nullptr; 227 return nullptr;
228 228
229 scoped_ptr<base::SharedMemory> new_shared_mem(new base::SharedMemory); 229 std::unique_ptr<base::SharedMemory> new_shared_mem(new base::SharedMemory);
230 if (new_shared_mem->CreateAndMapAnonymous(buffer_size)) { 230 if (new_shared_mem->CreateAndMapAnonymous(buffer_size)) {
231 if (void* mem = new_shared_mem->memory()) { 231 if (void* mem = new_shared_mem->memory()) {
232 memset(mem, 0, buffer_size); 232 memset(mem, 0, buffer_size);
233 base::SharedMemory* shared_mem = new_shared_mem.release(); 233 base::SharedMemory* shared_mem = new_shared_mem.release();
234 shared_memory_map_[consumer_type] = shared_mem; 234 shared_memory_map_[consumer_type] = shared_mem;
235 return shared_mem; 235 return shared_mem;
236 } 236 }
237 } 237 }
238 LOG(ERROR) << "Failed to initialize shared memory"; 238 LOG(ERROR) << "Failed to initialize shared memory";
239 return nullptr; 239 return nullptr;
240 } 240 }
241 241
242 void* DataFetcherSharedMemoryBase::GetSharedMemoryBuffer( 242 void* DataFetcherSharedMemoryBase::GetSharedMemoryBuffer(
243 ConsumerType consumer_type) { 243 ConsumerType consumer_type) {
244 if (base::SharedMemory* shared_memory = GetSharedMemory(consumer_type)) 244 if (base::SharedMemory* shared_memory = GetSharedMemory(consumer_type))
245 return shared_memory->memory(); 245 return shared_memory->memory();
246 return nullptr; 246 return nullptr;
247 } 247 }
248 248
249 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const { 249 base::MessageLoop* DataFetcherSharedMemoryBase::GetPollingMessageLoop() const {
250 return polling_thread_ ? polling_thread_->message_loop() : nullptr; 250 return polling_thread_ ? polling_thread_->message_loop() : nullptr;
251 } 251 }
252 252
253 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const { 253 bool DataFetcherSharedMemoryBase::IsPollingTimerRunningForTesting() const {
254 return polling_thread_ ? polling_thread_->IsTimerRunning() : false; 254 return polling_thread_ ? polling_thread_->IsTimerRunning() : false;
255 } 255 }
256 256
257 } // namespace content 257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698