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

Side by Side Diff: chrome/browser/chromeos/memory/oom_memory_details.cc

Issue 1188823002: [MemoryPressure] Move chrome/browser/chromeos/* to chrome/browser/memory/*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sky@ comments. Created 5 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/memory/oom_memory_details.h"
6
7 #include "base/logging.h"
8 #include "base/process/process_metrics.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/memory/oom_memory_details.h"
11 #include "ui/base/text/bytes_formatting.h"
12
13 namespace chromeos {
14
15 // static
16 void OomMemoryDetails::Log(const std::string& title,
17 const base::Closure& callback) {
18 // Deletes itself upon completion.
19 OomMemoryDetails* details = new OomMemoryDetails(title, callback);
20 details->StartFetch(MemoryDetails::FROM_CHROME_ONLY);
21 }
22
23 OomMemoryDetails::OomMemoryDetails(const std::string& title,
24 const base::Closure& callback)
25 : title_(title), callback_(callback) {
26 AddRef(); // Released in OnDetailsAvailable().
27 start_time_ = base::TimeTicks::Now();
28 }
29
30 OomMemoryDetails::~OomMemoryDetails() {
31 }
32
33 void OomMemoryDetails::OnDetailsAvailable() {
34 base::TimeDelta delta = base::TimeTicks::Now() - start_time_;
35 // These logs are collected by user feedback reports. We want them to help
36 // diagnose user-reported problems with frequently discarded tabs.
37 std::string log_string = ToLogString();
38 base::SystemMemoryInfoKB memory;
39 if (base::GetSystemMemoryInfo(&memory) && memory.gem_size != -1) {
40 log_string += "Graphics ";
41 log_string += base::UTF16ToASCII(ui::FormatBytes(memory.gem_size));
42 }
43 LOG(WARNING) << title_ << " (" << delta.InMilliseconds() << " ms):\n"
44 << log_string;
45 if (!callback_.is_null())
46 callback_.Run();
47 // Delete ourselves so we don't have to worry about OomPriorityManager
48 // deleting us when we're still working.
49 Release();
50 }
51
52 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/memory/oom_memory_details.h ('k') | chrome/browser/chromeos/memory/oom_priority_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698