OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/tools/test_shell/simple_appcache_system.h" | 5 #include "webkit/tools/test_shell/simple_appcache_system.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/lock.h" | 8 #include "base/lock.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/waitable_event.h" | 10 #include "base/waitable_event.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class SimpleFrontendProxy | 52 class SimpleFrontendProxy |
53 : public base::RefCountedThreadSafe<SimpleFrontendProxy>, | 53 : public base::RefCountedThreadSafe<SimpleFrontendProxy>, |
54 public appcache::AppCacheFrontend { | 54 public appcache::AppCacheFrontend { |
55 public: | 55 public: |
56 explicit SimpleFrontendProxy(SimpleAppCacheSystem* appcache_system) | 56 explicit SimpleFrontendProxy(SimpleAppCacheSystem* appcache_system) |
57 : system_(appcache_system) { | 57 : system_(appcache_system) { |
58 } | 58 } |
59 | 59 |
60 void clear_appcache_system() { system_ = NULL; } | 60 void clear_appcache_system() { system_ = NULL; } |
61 | 61 |
62 virtual void OnCacheSelected(int host_id, int64 cache_id , | 62 virtual void OnCacheSelected(int host_id, |
63 appcache::Status status) { | 63 const appcache::AppCacheInfo& info) { |
64 if (!system_) | 64 if (!system_) |
65 return; | 65 return; |
66 if (system_->is_io_thread()) | 66 if (system_->is_io_thread()) |
67 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 67 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
68 this, &SimpleFrontendProxy::OnCacheSelected, | 68 this, &SimpleFrontendProxy::OnCacheSelected, |
69 host_id, cache_id, status)); | 69 host_id, info)); |
70 else if (system_->is_ui_thread()) | 70 else if (system_->is_ui_thread()) { |
71 system_->frontend_impl_.OnCacheSelected(host_id, cache_id, status); | 71 system_->frontend_impl_.OnCacheSelected(host_id, info); |
| 72 } |
72 else | 73 else |
73 NOTREACHED(); | 74 NOTREACHED(); |
74 } | 75 } |
75 | 76 |
76 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 77 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
77 appcache::Status status) { | 78 appcache::Status status) { |
78 if (!system_) | 79 if (!system_) |
79 return; | 80 return; |
80 if (system_->is_io_thread()) | 81 if (system_->is_io_thread()) |
81 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 82 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 cache_document_was_loaded_from, manifest_url)); | 207 cache_document_was_loaded_from, manifest_url)); |
207 } else if (system_->is_io_thread()) { | 208 } else if (system_->is_io_thread()) { |
208 system_->backend_impl_->SelectCache(host_id, document_url, | 209 system_->backend_impl_->SelectCache(host_id, document_url, |
209 cache_document_was_loaded_from, | 210 cache_document_was_loaded_from, |
210 manifest_url); | 211 manifest_url); |
211 } else { | 212 } else { |
212 NOTREACHED(); | 213 NOTREACHED(); |
213 } | 214 } |
214 } | 215 } |
215 | 216 |
| 217 virtual void GetResourceList( |
| 218 int host_id, |
| 219 std::vector<appcache::AppCacheResourceInfo>* resource_infos) { |
| 220 if (system_->is_ui_thread()) { |
| 221 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 222 this, &SimpleBackendProxy::GetResourceList, |
| 223 host_id, resource_infos)); |
| 224 } else if (system_->is_io_thread()) { |
| 225 system_->backend_impl_->GetResourceList(host_id, resource_infos); |
| 226 } else { |
| 227 NOTREACHED(); |
| 228 } |
| 229 } |
| 230 |
216 virtual void SelectCacheForWorker( | 231 virtual void SelectCacheForWorker( |
217 int host_id, | 232 int host_id, |
218 int parent_process_id, | 233 int parent_process_id, |
219 int parent_host_id) { | 234 int parent_host_id) { |
220 NOTIMPLEMENTED(); // Workers are not supported in test_shell. | 235 NOTIMPLEMENTED(); // Workers are not supported in test_shell. |
221 } | 236 } |
222 | 237 |
223 virtual void SelectCacheForSharedWorker( | 238 virtual void SelectCacheForSharedWorker( |
224 int host_id, | 239 int host_id, |
225 int64 appcache_id) { | 240 int64 appcache_id) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 444 |
430 delete backend_impl_; | 445 delete backend_impl_; |
431 delete service_; | 446 delete service_; |
432 backend_impl_ = NULL; | 447 backend_impl_ = NULL; |
433 service_ = NULL; | 448 service_ = NULL; |
434 io_message_loop_ = NULL; | 449 io_message_loop_ = NULL; |
435 | 450 |
436 // Just in case the main thread is waiting on it. | 451 // Just in case the main thread is waiting on it. |
437 backend_proxy_->SignalEvent(); | 452 backend_proxy_->SignalEvent(); |
438 } | 453 } |
OLD | NEW |