Index: components/framelet/browser/framelet_memory_tracker.h |
diff --git a/components/framelet/browser/framelet_memory_tracker.h b/components/framelet/browser/framelet_memory_tracker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..19a60e0c375aadf1ae08e9a7af0eea8c9ee52454 |
--- /dev/null |
+++ b/components/framelet/browser/framelet_memory_tracker.h |
@@ -0,0 +1,66 @@ |
+// Copyright 2015 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. |
+ |
+#ifndef COMPONENTS_FRAMELET_BROWSER_FRAMELET_MEMORY_TRACKER_H_ |
+#define COMPONENTS_FRAMELET_BROWSER_FRAMELET_MEMORY_TRACKER_H_ |
+ |
+#include <set> |
+ |
+#include "base/supports_user_data.h" |
+#include "base/timer/timer.h" |
+ |
+namespace content { |
+class BrowserContext; |
+} |
+ |
+namespace framelet { |
+ |
+class FrameletMemoryTrackerClient; |
+ |
+class FrameletMemoryTracker : public base::SupportsUserData::Data { |
+ public: |
+ class ClientID { |
+ public: |
+ ClientID(); |
+ ClientID(int render_process_id, int routing_id); |
+ ~ClientID(); |
+ |
+ int render_process_id() const { return render_process_id_; } |
+ int routing_id() const { return routing_id_; } |
+ |
+ bool operator<(const ClientID& other) const; |
+ bool operator==(const ClientID& other) const; |
+ |
+ private: |
+ const int render_process_id_; |
+ const int routing_id_; |
+ }; |
+ |
+ // Returns the FrameletMemoryTracker associated with |context|. If one isn't |
+ // available, then it is created and returned. |
+ static FrameletMemoryTracker* FromBrowserContext( |
+ content::BrowserContext* context); |
+ |
+ void ReportHeapSize(const ClientID& client_id, int heap_size); |
+ |
+ void AddClient(const ClientID& client_id, |
+ FrameletMemoryTrackerClient* framelet); |
+ void RemoveClient(const ClientID& client_id); |
+ |
+ private: |
+ FrameletMemoryTracker(); |
+ ~FrameletMemoryTracker() override; |
+ |
+ void OnElapsedTime(); |
+ |
+ std::map<ClientID, FrameletMemoryTrackerClient*> clients_; |
+ std::set<ClientID> acks_pending_; |
+ base::RepeatingTimer timer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FrameletMemoryTracker); |
+}; |
+ |
+} // namespace framelet |
+ |
+#endif // COMPONENTS_FRAMELET_BROWSER_FRAMELET_MEMORY_TRACKER_H_ |