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

Unified Diff: chrome/browser/chromeos/system/memorydetails_fetcher.cc

Issue 10827130: Refactoring the SysInfoProvider. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system/memorydetails_fetcher.cc
diff --git a/chrome/browser/chromeos/system/memorydetails_fetcher.cc b/chrome/browser/chromeos/system/memorydetails_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..63cb4b937543a882fcc5890126211e6f44102e6e
--- /dev/null
+++ b/chrome/browser/chromeos/system/memorydetails_fetcher.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 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.
+
+#include "chrome/browser/chromeos/system/memorydetails_fetcher.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/string_util.h"
+#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread.h"
+#include "chrome/browser/chromeos/system/syslogs_fetcher.h"
+#include "chrome/browser/memory_details.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace chromeos {
+namespace system {
+
+class SysLogsFetcherMemoryHandler : public MemoryDetails {
+ public:
+
+ SysLogsFetcherMemoryHandler(
+ SysLogsFetcherCallback request)
+ : request_(request) { }
+
+ virtual void OnDetailsAvailable() OVERRIDE {
+ SysInfoResponse* response = new SysInfoResponse;
+ (*response)["mem_usage"] = ToLogString();
+ // This will call the callback on the calling thread.
+ request_.Run(response);
+ }
+
+ private:
+ virtual ~SysLogsFetcherMemoryHandler() {}
+ SysLogsFetcherCallback request_;
rkc1 2012/08/04 01:15:05 Indentation.
tudalex(Chromium) 2012/08/05 01:15:12 Done.
+ DISALLOW_COPY_AND_ASSIGN(SysLogsFetcherMemoryHandler);
rkc1 2012/08/04 01:15:05 Newline above.
tudalex(Chromium) 2012/08/05 01:15:12 Done.
+ };
+
+void MemoryDetailsFetcher::Fetch(SysLogsFetcherCallback request){
+ scoped_refptr<SysLogsFetcherMemoryHandler>
+ handler(new SysLogsFetcherMemoryHandler(request));
+ // TODO(jamescook): Maybe we don't need to update histograms here?
+ handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS);
+}
+
+} // namespace system
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698