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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/app/memory_monitor.mm
diff --git a/ios/chrome/app/memory_monitor.mm b/ios/chrome/app/memory_monitor.mm
new file mode 100644
index 0000000000000000000000000000000000000000..162b156662d46aa3e962b85535923f0e1c9b1caa
--- /dev/null
+++ b/ios/chrome/app/memory_monitor.mm
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/app/memory_monitor.h"
+
+#include <dispatch/dispatch.h>
+#import <Foundation/NSPathUtilities.h>
+
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/location.h"
+#include "base/logging.h"
+#import "base/mac/foundation_util.h"
+#include "base/strings/sys_string_conversions.h"
+#include "base/sys_info.h"
+#import "ios/chrome/browser/crash_report/breakpad_helper.h"
+#include "ios/web/public/web_thread.h"
+
+namespace ios_internal {
+
+void AsynchronousFreeMemoryMonitor() {
+ UpdateBreakpadMemoryValues();
+ web::WebThread::PostDelayedTask(
+ web::WebThread::FILE, FROM_HERE,
+ base::Bind(&ios_internal::AsynchronousFreeMemoryMonitor),
+ base::TimeDelta::FromSeconds(30));
+}
+
+void UpdateBreakpadMemoryValues() {
+ int freeMemory =
+ static_cast<int>(base::SysInfo::AmountOfAvailablePhysicalMemory() / 1024);
+ breakpad_helper::SetCurrentFreeMemoryInKB(freeMemory);
+ NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
+ NSUserDomainMask, YES);
+ NSString* value = base::mac::ObjCCastStrict<NSString>([paths lastObject]);
+ base::FilePath filePath = base::FilePath(base::SysNSStringToUTF8(value));
+ int freeDiskSpace =
+ static_cast<int>(base::SysInfo::AmountOfFreeDiskSpace(filePath) / 1024);
+ breakpad_helper::SetCurrentFreeDiskInKB(freeDiskSpace);
+}
+}
« 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