1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_MEMORY_INTERNALS_MEMORY_INTERNALS_PROXY_H_
6 #define CHROME_BROWSER_UI_WEBUI_MEMORY_INTERNALS_MEMORY_INTERNALS_PROXY_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/strings/string16.h"
13 #include "base/values.h"
14 #include "chrome/browser/memory_details.h"
15 #include "content/public/browser/browser_thread.h"
17 class MemoryInternalsHandler
;
18 class RendererDetails
;
21 class DictionaryValue
;
30 class MemoryInternalsProxy
31 : public base::RefCountedThreadSafe
<
32 MemoryInternalsProxy
, content::BrowserThread::DeleteOnUIThread
> {
34 MemoryInternalsProxy();
36 // Registers a handler.
37 void Attach(MemoryInternalsHandler
* handler
);
39 // Unregisters a handler.
42 // Starts fetching memory usages of all processes.
43 void StartFetch(const base::ListValue
* list
);
47 content::BrowserThread::DeleteOnThread
<content::BrowserThread::UI
>;
48 friend class base::DeleteHelper
<MemoryInternalsProxy
>;
50 typedef ProcessMemoryInformationList::const_iterator PMIIterator
;
52 virtual ~MemoryInternalsProxy();
54 // Enumerates all processes information.
55 void OnProcessAvailable(const ProcessData
& browser
);
57 // Measures memory usage of V8.
58 void OnRendererAvailable(const base::ProcessId pid
,
59 const size_t v8_allocated
,
60 const size_t v8_used
);
62 // Converts information related to each WebContents, which represents contents
63 // in a tab, into Value format and appends it to information of the process
64 // which each tab belongs to.
65 void ConvertTabsInformation(
66 const std::set
<content::WebContents
*>& web_contents
,
67 base::ListValue
* processes
);
69 // Requests all renderer processes to get detailed memory information.
70 void RequestRendererDetails();
72 // Be called on finish of collection.
73 void FinishCollection();
75 // Calls a JavaScript function on a UI page.
76 void CallJavaScriptFunctionOnUIThread(const std::string
& function
,
77 const base::Value
& args
);
79 MemoryInternalsHandler
* handler_
;
80 base::DictionaryValue
* information_
;
81 RendererDetails
* renderer_details_
;
83 DISALLOW_COPY_AND_ASSIGN(MemoryInternalsProxy
);
86 #endif // CHROME_BROWSER_UI_WEBUI_MEMORY_INTERNALS_MEMORY_INTERNALS_PROXY_H_