OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/browser/appcache/appcache.h" | 9 #include "content/browser/appcache/appcache.h" |
10 #include "content/browser/appcache/appcache_backend_impl.h" | 10 #include "content/browser/appcache/appcache_backend_impl.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 public: | 36 public: |
37 MockFrontend() | 37 MockFrontend() |
38 : last_host_id_(-222), last_cache_id_(-222), | 38 : last_host_id_(-222), last_cache_id_(-222), |
39 last_status_(APPCACHE_STATUS_OBSOLETE), | 39 last_status_(APPCACHE_STATUS_OBSOLETE), |
40 last_status_changed_(APPCACHE_STATUS_OBSOLETE), | 40 last_status_changed_(APPCACHE_STATUS_OBSOLETE), |
41 last_event_id_(APPCACHE_OBSOLETE_EVENT), | 41 last_event_id_(APPCACHE_OBSOLETE_EVENT), |
42 content_blocked_(false) { | 42 content_blocked_(false) { |
43 } | 43 } |
44 | 44 |
45 virtual void OnCacheSelected( | 45 virtual void OnCacheSelected( |
46 int host_id, const AppCacheInfo& info) OVERRIDE { | 46 int host_id, const AppCacheInfo& info) override { |
47 last_host_id_ = host_id; | 47 last_host_id_ = host_id; |
48 last_cache_id_ = info.cache_id; | 48 last_cache_id_ = info.cache_id; |
49 last_status_ = info.status; | 49 last_status_ = info.status; |
50 } | 50 } |
51 | 51 |
52 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 52 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
53 AppCacheStatus status) OVERRIDE { | 53 AppCacheStatus status) override { |
54 last_status_changed_ = status; | 54 last_status_changed_ = status; |
55 } | 55 } |
56 | 56 |
57 virtual void OnEventRaised(const std::vector<int>& host_ids, | 57 virtual void OnEventRaised(const std::vector<int>& host_ids, |
58 AppCacheEventID event_id) OVERRIDE { | 58 AppCacheEventID event_id) override { |
59 last_event_id_ = event_id; | 59 last_event_id_ = event_id; |
60 } | 60 } |
61 | 61 |
62 virtual void OnErrorEventRaised( | 62 virtual void OnErrorEventRaised( |
63 const std::vector<int>& host_ids, | 63 const std::vector<int>& host_ids, |
64 const AppCacheErrorDetails& details) OVERRIDE { | 64 const AppCacheErrorDetails& details) override { |
65 last_event_id_ = APPCACHE_ERROR_EVENT; | 65 last_event_id_ = APPCACHE_ERROR_EVENT; |
66 } | 66 } |
67 | 67 |
68 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, | 68 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
69 const GURL& url, | 69 const GURL& url, |
70 int num_total, | 70 int num_total, |
71 int num_complete) OVERRIDE { | 71 int num_complete) override { |
72 last_event_id_ = APPCACHE_PROGRESS_EVENT; | 72 last_event_id_ = APPCACHE_PROGRESS_EVENT; |
73 } | 73 } |
74 | 74 |
75 virtual void OnLogMessage(int host_id, | 75 virtual void OnLogMessage(int host_id, |
76 AppCacheLogLevel log_level, | 76 AppCacheLogLevel log_level, |
77 const std::string& message) OVERRIDE { | 77 const std::string& message) override { |
78 } | 78 } |
79 | 79 |
80 virtual void OnContentBlocked(int host_id, | 80 virtual void OnContentBlocked(int host_id, |
81 const GURL& manifest_url) OVERRIDE { | 81 const GURL& manifest_url) override { |
82 content_blocked_ = true; | 82 content_blocked_ = true; |
83 } | 83 } |
84 | 84 |
85 int last_host_id_; | 85 int last_host_id_; |
86 int64 last_cache_id_; | 86 int64 last_cache_id_; |
87 AppCacheStatus last_status_; | 87 AppCacheStatus last_status_; |
88 AppCacheStatus last_status_changed_; | 88 AppCacheStatus last_status_changed_; |
89 AppCacheEventID last_event_id_; | 89 AppCacheEventID last_event_id_; |
90 bool content_blocked_; | 90 bool content_blocked_; |
91 }; | 91 }; |
92 | 92 |
93 class MockQuotaManagerProxy : public storage::QuotaManagerProxy { | 93 class MockQuotaManagerProxy : public storage::QuotaManagerProxy { |
94 public: | 94 public: |
95 MockQuotaManagerProxy() : QuotaManagerProxy(NULL, NULL) {} | 95 MockQuotaManagerProxy() : QuotaManagerProxy(NULL, NULL) {} |
96 | 96 |
97 // Not needed for our tests. | 97 // Not needed for our tests. |
98 virtual void RegisterClient(storage::QuotaClient* client) OVERRIDE {} | 98 virtual void RegisterClient(storage::QuotaClient* client) override {} |
99 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id, | 99 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id, |
100 const GURL& origin, | 100 const GURL& origin, |
101 storage::StorageType type) OVERRIDE {} | 101 storage::StorageType type) override {} |
102 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, | 102 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, |
103 const GURL& origin, | 103 const GURL& origin, |
104 storage::StorageType type, | 104 storage::StorageType type, |
105 int64 delta) OVERRIDE {} | 105 int64 delta) override {} |
106 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, | 106 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, |
107 const GURL& origin, | 107 const GURL& origin, |
108 storage::StorageType type, | 108 storage::StorageType type, |
109 bool enabled) OVERRIDE {} | 109 bool enabled) override {} |
110 virtual void GetUsageAndQuota( | 110 virtual void GetUsageAndQuota( |
111 base::SequencedTaskRunner* original_task_runner, | 111 base::SequencedTaskRunner* original_task_runner, |
112 const GURL& origin, | 112 const GURL& origin, |
113 storage::StorageType type, | 113 storage::StorageType type, |
114 const GetUsageAndQuotaCallback& callback) OVERRIDE {} | 114 const GetUsageAndQuotaCallback& callback) override {} |
115 | 115 |
116 virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE { | 116 virtual void NotifyOriginInUse(const GURL& origin) override { |
117 inuse_[origin] += 1; | 117 inuse_[origin] += 1; |
118 } | 118 } |
119 | 119 |
120 virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE { | 120 virtual void NotifyOriginNoLongerInUse(const GURL& origin) override { |
121 inuse_[origin] -= 1; | 121 inuse_[origin] -= 1; |
122 } | 122 } |
123 | 123 |
124 int GetInUseCount(const GURL& origin) { | 124 int GetInUseCount(const GURL& origin) { |
125 return inuse_[origin]; | 125 return inuse_[origin]; |
126 } | 126 } |
127 | 127 |
128 void reset() { | 128 void reset() { |
129 inuse_.clear(); | 129 inuse_.clear(); |
130 } | 130 } |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 EXPECT_EQ(&mock_frontend_, host.frontend()); | 531 EXPECT_EQ(&mock_frontend_, host.frontend()); |
532 EXPECT_EQ(NULL, host.associated_cache()); | 532 EXPECT_EQ(NULL, host.associated_cache()); |
533 EXPECT_FALSE(host.is_selection_pending()); | 533 EXPECT_FALSE(host.is_selection_pending()); |
534 EXPECT_TRUE(host.preferred_manifest_url().is_empty()); | 534 EXPECT_TRUE(host.preferred_manifest_url().is_empty()); |
535 } | 535 } |
536 EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); | 536 EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); |
537 service_.set_quota_manager_proxy(NULL); | 537 service_.set_quota_manager_proxy(NULL); |
538 } | 538 } |
539 | 539 |
540 } // namespace content | 540 } // namespace content |
OLD | NEW |