| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_MEMORY_INTERNALS_MEMORY_INTERNALS_PROXY_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_MEMORY_INTERNALS_MEMORY_INTERNALS_PROXY_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include <set> | |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/strings/string16.h" | |
| 17 #include "base/values.h" | |
| 18 #include "chrome/browser/memory_details.h" | |
| 19 #include "content/public/browser/browser_thread.h" | |
| 20 | |
| 21 class MemoryInternalsHandler; | |
| 22 class RendererDetails; | |
| 23 | |
| 24 namespace base { | |
| 25 class DictionaryValue; | |
| 26 class ListValue; | |
| 27 class Value; | |
| 28 } | |
| 29 | |
| 30 namespace content { | |
| 31 class WebContents; | |
| 32 } | |
| 33 | |
| 34 class MemoryInternalsProxy | |
| 35 : public base::RefCountedThreadSafe< | |
| 36 MemoryInternalsProxy, content::BrowserThread::DeleteOnUIThread> { | |
| 37 public: | |
| 38 MemoryInternalsProxy(); | |
| 39 | |
| 40 // Registers a handler. | |
| 41 void Attach(MemoryInternalsHandler* handler); | |
| 42 | |
| 43 // Unregisters a handler. | |
| 44 void Detach(); | |
| 45 | |
| 46 // Starts fetching memory usages of all processes. | |
| 47 void StartFetch(const base::ListValue* list); | |
| 48 | |
| 49 private: | |
| 50 friend struct | |
| 51 content::BrowserThread::DeleteOnThread<content::BrowserThread::UI>; | |
| 52 friend class base::DeleteHelper<MemoryInternalsProxy>; | |
| 53 | |
| 54 typedef ProcessMemoryInformationList::const_iterator PMIIterator; | |
| 55 | |
| 56 virtual ~MemoryInternalsProxy(); | |
| 57 | |
| 58 // Enumerates all processes information. | |
| 59 void OnProcessAvailable(const ProcessData& browser); | |
| 60 | |
| 61 // Measures memory usage of V8. | |
| 62 void OnRendererAvailable(const base::ProcessId pid, | |
| 63 const size_t v8_allocated, | |
| 64 const size_t v8_used); | |
| 65 | |
| 66 // Converts information related to each WebContents, which represents contents | |
| 67 // in a tab, into Value format and appends it to information of the process | |
| 68 // which each tab belongs to. | |
| 69 void ConvertTabsInformation( | |
| 70 const std::set<content::WebContents*>& web_contents, | |
| 71 base::ListValue* processes); | |
| 72 | |
| 73 // Requests all renderer processes to get detailed memory information. | |
| 74 void RequestRendererDetails(); | |
| 75 | |
| 76 // Be called on finish of collection. | |
| 77 void FinishCollection(); | |
| 78 | |
| 79 // Calls a JavaScript function on a UI page. | |
| 80 void CallJavaScriptFunctionOnUIThread(const std::string& function, | |
| 81 const base::Value& args); | |
| 82 | |
| 83 MemoryInternalsHandler* handler_; | |
| 84 base::DictionaryValue* information_; | |
| 85 scoped_ptr<RendererDetails> renderer_details_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(MemoryInternalsProxy); | |
| 88 }; | |
| 89 | |
| 90 #endif // CHROME_BROWSER_UI_WEBUI_MEMORY_INTERNALS_MEMORY_INTERNALS_PROXY_H_ | |
| OLD | NEW |