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

Side by Side Diff: components/discardable_memory/client/client_discardable_shared_memory_manager.cc

Issue 2548423002: Hosting the discardable memory service in the mus process (Closed)
Patch Set: Rebase Created 4 years 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 | « no previous file | content/browser/browser_main_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/discardable_memory/client/client_discardable_shared_memory_ manager.h" 5 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 MemoryUsageChanged(0, 0); 121 MemoryUsageChanged(0, 0);
122 122
123 // Releasing the |heap_| before posting a task for deleting |manager_mojo_|. 123 // Releasing the |heap_| before posting a task for deleting |manager_mojo_|.
124 // It is because releasing |heap_| will invoke DeletedDiscardableSharedMemory 124 // It is because releasing |heap_| will invoke DeletedDiscardableSharedMemory
125 // which needs |manager_mojo_|. 125 // which needs |manager_mojo_|.
126 heap_.reset(); 126 heap_.reset();
127 127
128 // Delete the |manager_mojo_| on IO thread, so any pending tasks on IO thread 128 // Delete the |manager_mojo_| on IO thread, so any pending tasks on IO thread
129 // will be executed before the |manager_mojo_| is deleted. 129 // will be executed before the |manager_mojo_| is deleted.
130 bool posted = io_task_runner_->DeleteSoon(FROM_HERE, manager_mojo_.release()); 130 bool posted = io_task_runner_->DeleteSoon(FROM_HERE, manager_mojo_.release());
131 DCHECK(posted); 131 if (!posted)
132 manager_mojo_.reset();
132 } 133 }
133 134
134 std::unique_ptr<base::DiscardableMemory> 135 std::unique_ptr<base::DiscardableMemory>
135 ClientDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory( 136 ClientDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory(
136 size_t size) { 137 size_t size) {
137 base::AutoLock lock(lock_); 138 base::AutoLock lock(lock_);
138 139
139 DCHECK_NE(size, 0u); 140 DCHECK_NE(size, 0u);
140 141
141 auto size_in_kb = static_cast<base::HistogramBase::Sample>(size / 1024); 142 auto size_in_kb = static_cast<base::HistogramBase::Sample>(size / 1024);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 "discardable-memory-allocated"; 414 "discardable-memory-allocated";
414 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, 415 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey,
415 base::Uint64ToString(new_bytes_total)); 416 base::Uint64ToString(new_bytes_total));
416 417
417 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; 418 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free";
418 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, 419 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey,
419 base::Uint64ToString(new_bytes_free)); 420 base::Uint64ToString(new_bytes_free));
420 } 421 }
421 422
422 } // namespace discardable_memory 423 } // namespace discardable_memory
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698