| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/dom_storage/dom_storage_dispatcher.h" | 5 #include "content/renderer/dom_storage/dom_storage_dispatcher.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 public: | 34 public: |
| 35 explicit MessageThrottlingFilter(RenderThreadImpl* sender) | 35 explicit MessageThrottlingFilter(RenderThreadImpl* sender) |
| 36 : pending_count_(0), sender_(sender) {} | 36 : pending_count_(0), sender_(sender) {} |
| 37 | 37 |
| 38 void SendThrottled(IPC::Message* message); | 38 void SendThrottled(IPC::Message* message); |
| 39 void Shutdown() { sender_ = NULL; } | 39 void Shutdown() { sender_ = NULL; } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 virtual ~MessageThrottlingFilter() {} | 42 virtual ~MessageThrottlingFilter() {} |
| 43 | 43 |
| 44 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 44 virtual bool OnMessageReceived(const IPC::Message& message) override; |
| 45 | 45 |
| 46 int GetPendingCount() { return IncrementPendingCountN(0); } | 46 int GetPendingCount() { return IncrementPendingCountN(0); } |
| 47 int IncrementPendingCount() { return IncrementPendingCountN(1); } | 47 int IncrementPendingCount() { return IncrementPendingCountN(1); } |
| 48 int DecrementPendingCount() { return IncrementPendingCountN(-1); } | 48 int DecrementPendingCount() { return IncrementPendingCountN(-1); } |
| 49 int IncrementPendingCountN(int increment) { | 49 int IncrementPendingCountN(int increment) { |
| 50 base::AutoLock locker(lock_); | 50 base::AutoLock locker(lock_); |
| 51 pending_count_ += increment; | 51 pending_count_ += increment; |
| 52 return pending_count_; | 52 return pending_count_; |
| 53 } | 53 } |
| 54 | 54 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void CloseCachedArea(DOMStorageCachedArea* area); | 104 void CloseCachedArea(DOMStorageCachedArea* area); |
| 105 DOMStorageCachedArea* LookupCachedArea( | 105 DOMStorageCachedArea* LookupCachedArea( |
| 106 int64 namespace_id, const GURL& origin); | 106 int64 namespace_id, const GURL& origin); |
| 107 void ResetAllCachedAreas(int64 namespace_id); | 107 void ResetAllCachedAreas(int64 namespace_id); |
| 108 void CompleteOnePendingCallback(bool success); | 108 void CompleteOnePendingCallback(bool success); |
| 109 void Shutdown(); | 109 void Shutdown(); |
| 110 | 110 |
| 111 // DOMStorageProxy interface for use by DOMStorageCachedArea. | 111 // DOMStorageProxy interface for use by DOMStorageCachedArea. |
| 112 virtual void LoadArea(int connection_id, DOMStorageValuesMap* values, | 112 virtual void LoadArea(int connection_id, DOMStorageValuesMap* values, |
| 113 bool* send_log_get_messages, | 113 bool* send_log_get_messages, |
| 114 const CompletionCallback& callback) OVERRIDE; | 114 const CompletionCallback& callback) override; |
| 115 virtual void SetItem(int connection_id, const base::string16& key, | 115 virtual void SetItem(int connection_id, const base::string16& key, |
| 116 const base::string16& value, const GURL& page_url, | 116 const base::string16& value, const GURL& page_url, |
| 117 const CompletionCallback& callback) OVERRIDE; | 117 const CompletionCallback& callback) override; |
| 118 virtual void LogGetItem(int connection_id, const base::string16& key, | 118 virtual void LogGetItem(int connection_id, const base::string16& key, |
| 119 const base::NullableString16& value) OVERRIDE; | 119 const base::NullableString16& value) override; |
| 120 virtual void RemoveItem(int connection_id, const base::string16& key, | 120 virtual void RemoveItem(int connection_id, const base::string16& key, |
| 121 const GURL& page_url, | 121 const GURL& page_url, |
| 122 const CompletionCallback& callback) OVERRIDE; | 122 const CompletionCallback& callback) override; |
| 123 virtual void ClearArea(int connection_id, | 123 virtual void ClearArea(int connection_id, |
| 124 const GURL& page_url, | 124 const GURL& page_url, |
| 125 const CompletionCallback& callback) OVERRIDE; | 125 const CompletionCallback& callback) override; |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 // Struct to hold references to our contained areas and | 128 // Struct to hold references to our contained areas and |
| 129 // to keep track of how many tabs have a given area open. | 129 // to keep track of how many tabs have a given area open. |
| 130 struct CachedAreaHolder { | 130 struct CachedAreaHolder { |
| 131 scoped_refptr<DOMStorageCachedArea> area_; | 131 scoped_refptr<DOMStorageCachedArea> area_; |
| 132 int open_count_; | 132 int open_count_; |
| 133 int64 namespace_id_; | 133 int64 namespace_id_; |
| 134 CachedAreaHolder() : open_count_(0) {} | 134 CachedAreaHolder() : open_count_(0) {} |
| 135 CachedAreaHolder(DOMStorageCachedArea* area, int count, | 135 CachedAreaHolder(DOMStorageCachedArea* area, int count, |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) { | 356 void DomStorageDispatcher::OnAsyncOperationComplete(bool success) { |
| 357 proxy_->CompleteOnePendingCallback(success); | 357 proxy_->CompleteOnePendingCallback(success); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void DomStorageDispatcher::OnResetCachedValues(int64 namespace_id) { | 360 void DomStorageDispatcher::OnResetCachedValues(int64 namespace_id) { |
| 361 proxy_->ResetAllCachedAreas(namespace_id); | 361 proxy_->ResetAllCachedAreas(namespace_id); |
| 362 } | 362 } |
| 363 | 363 |
| 364 } // namespace content | 364 } // namespace content |
| OLD | NEW |