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

Side by Side Diff: ios/chrome/app/memory_monitor.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/app/memory_monitor.h"
6
7 #include <dispatch/dispatch.h>
8 #import <Foundation/NSPathUtilities.h>
9
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
12 #include "base/location.h"
13 #include "base/logging.h"
14 #import "base/mac/foundation_util.h"
15 #include "base/strings/sys_string_conversions.h"
16 #include "base/sys_info.h"
17 #import "ios/chrome/browser/crash_report/breakpad_helper.h"
18 #include "ios/web/public/web_thread.h"
19
20 namespace ios_internal {
21
22 void AsynchronousFreeMemoryMonitor() {
23 UpdateBreakpadMemoryValues();
24 web::WebThread::PostDelayedTask(
25 web::WebThread::FILE, FROM_HERE,
26 base::Bind(&ios_internal::AsynchronousFreeMemoryMonitor),
27 base::TimeDelta::FromSeconds(30));
28 }
29
30 void UpdateBreakpadMemoryValues() {
31 int freeMemory =
32 static_cast<int>(base::SysInfo::AmountOfAvailablePhysicalMemory() / 1024);
33 breakpad_helper::SetCurrentFreeMemoryInKB(freeMemory);
34 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
35 NSUserDomainMask, YES);
36 NSString* value = base::mac::ObjCCastStrict<NSString>([paths lastObject]);
37 base::FilePath filePath = base::FilePath(base::SysNSStringToUTF8(value));
38 int freeDiskSpace =
39 static_cast<int>(base::SysInfo::AmountOfFreeDiskSpace(filePath) / 1024);
40 breakpad_helper::SetCurrentFreeDiskInKB(freeDiskSpace);
41 }
42 }
OLDNEW
« no previous file with comments | « ios/chrome/app/memory_monitor.h ('k') | ios/chrome/app/multitasking_test_application_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698