| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 11 #include "base/task.h" | 13 #include "base/task.h" |
| 12 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 13 #include "webkit/appcache/appcache_interceptor.h" | 15 #include "webkit/appcache/appcache_interceptor.h" |
| 14 #include "webkit/appcache/web_application_cache_host_impl.h" | 16 #include "webkit/appcache/web_application_cache_host_impl.h" |
| 15 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 17 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 16 | 18 |
| 17 using WebKit::WebApplicationCacheHost; | 19 using WebKit::WebApplicationCacheHost; |
| 18 using WebKit::WebApplicationCacheHostClient; | 20 using WebKit::WebApplicationCacheHostClient; |
| 19 using appcache::WebApplicationCacheHostImpl; | 21 using appcache::WebApplicationCacheHostImpl; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 : system_(appcache_system) { | 33 : system_(appcache_system) { |
| 32 } | 34 } |
| 33 | 35 |
| 34 void clear_appcache_system() { system_ = NULL; } | 36 void clear_appcache_system() { system_ = NULL; } |
| 35 | 37 |
| 36 virtual void OnCacheSelected(int host_id, | 38 virtual void OnCacheSelected(int host_id, |
| 37 const appcache::AppCacheInfo& info) { | 39 const appcache::AppCacheInfo& info) { |
| 38 if (!system_) | 40 if (!system_) |
| 39 return; | 41 return; |
| 40 if (system_->is_io_thread()) { | 42 if (system_->is_io_thread()) { |
| 41 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 43 system_->ui_message_loop()->PostTask( |
| 42 this, &SimpleFrontendProxy::OnCacheSelected, | 44 FROM_HERE, |
| 43 host_id, info)); | 45 base::Bind(&SimpleFrontendProxy::OnCacheSelected, this, host_id, |
| 46 info)); |
| 44 } else if (system_->is_ui_thread()) { | 47 } else if (system_->is_ui_thread()) { |
| 45 system_->frontend_impl_.OnCacheSelected(host_id, info); | 48 system_->frontend_impl_.OnCacheSelected(host_id, info); |
| 46 } else { | 49 } else { |
| 47 NOTREACHED(); | 50 NOTREACHED(); |
| 48 } | 51 } |
| 49 } | 52 } |
| 50 | 53 |
| 51 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 54 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
| 52 appcache::Status status) { | 55 appcache::Status status) { |
| 53 if (!system_) | 56 if (!system_) |
| 54 return; | 57 return; |
| 55 if (system_->is_io_thread()) | 58 if (system_->is_io_thread()) |
| 56 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 59 system_->ui_message_loop()->PostTask( |
| 57 this, &SimpleFrontendProxy::OnStatusChanged, host_ids, status)); | 60 FROM_HERE, |
| 61 base::Bind(&SimpleFrontendProxy::OnStatusChanged, this, host_ids, |
| 62 status)); |
| 58 else if (system_->is_ui_thread()) | 63 else if (system_->is_ui_thread()) |
| 59 system_->frontend_impl_.OnStatusChanged(host_ids, status); | 64 system_->frontend_impl_.OnStatusChanged(host_ids, status); |
| 60 else | 65 else |
| 61 NOTREACHED(); | 66 NOTREACHED(); |
| 62 } | 67 } |
| 63 | 68 |
| 64 virtual void OnEventRaised(const std::vector<int>& host_ids, | 69 virtual void OnEventRaised(const std::vector<int>& host_ids, |
| 65 appcache::EventID event_id) { | 70 appcache::EventID event_id) { |
| 66 if (!system_) | 71 if (!system_) |
| 67 return; | 72 return; |
| 68 if (system_->is_io_thread()) | 73 if (system_->is_io_thread()) |
| 69 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 74 system_->ui_message_loop()->PostTask( |
| 70 this, &SimpleFrontendProxy::OnEventRaised, host_ids, event_id)); | 75 FROM_HERE, |
| 76 base::Bind(&SimpleFrontendProxy::OnEventRaised, this, host_ids, |
| 77 event_id)); |
| 71 else if (system_->is_ui_thread()) | 78 else if (system_->is_ui_thread()) |
| 72 system_->frontend_impl_.OnEventRaised(host_ids, event_id); | 79 system_->frontend_impl_.OnEventRaised(host_ids, event_id); |
| 73 else | 80 else |
| 74 NOTREACHED(); | 81 NOTREACHED(); |
| 75 } | 82 } |
| 76 | 83 |
| 77 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, | 84 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
| 78 const GURL& url, | 85 const GURL& url, |
| 79 int num_total, int num_complete) { | 86 int num_total, int num_complete) { |
| 80 if (!system_) | 87 if (!system_) |
| 81 return; | 88 return; |
| 82 if (system_->is_io_thread()) | 89 if (system_->is_io_thread()) |
| 83 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 90 system_->ui_message_loop()->PostTask( |
| 84 this, &SimpleFrontendProxy::OnProgressEventRaised, | 91 FROM_HERE, |
| 85 host_ids, url, num_total, num_complete)); | 92 base::Bind(&SimpleFrontendProxy::OnProgressEventRaised, this, |
| 93 host_ids, url, num_total, num_complete)); |
| 86 else if (system_->is_ui_thread()) | 94 else if (system_->is_ui_thread()) |
| 87 system_->frontend_impl_.OnProgressEventRaised( | 95 system_->frontend_impl_.OnProgressEventRaised( |
| 88 host_ids, url, num_total, num_complete); | 96 host_ids, url, num_total, num_complete); |
| 89 else | 97 else |
| 90 NOTREACHED(); | 98 NOTREACHED(); |
| 91 } | 99 } |
| 92 | 100 |
| 93 virtual void OnErrorEventRaised(const std::vector<int>& host_ids, | 101 virtual void OnErrorEventRaised(const std::vector<int>& host_ids, |
| 94 const std::string& message) { | 102 const std::string& message) { |
| 95 if (!system_) | 103 if (!system_) |
| 96 return; | 104 return; |
| 97 if (system_->is_io_thread()) | 105 if (system_->is_io_thread()) |
| 98 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 106 system_->ui_message_loop()->PostTask( |
| 99 this, &SimpleFrontendProxy::OnErrorEventRaised, | 107 FROM_HERE, |
| 100 host_ids, message)); | 108 base::Bind(&SimpleFrontendProxy::OnErrorEventRaised, this, host_ids, |
| 109 message)); |
| 101 else if (system_->is_ui_thread()) | 110 else if (system_->is_ui_thread()) |
| 102 system_->frontend_impl_.OnErrorEventRaised( | 111 system_->frontend_impl_.OnErrorEventRaised( |
| 103 host_ids, message); | 112 host_ids, message); |
| 104 else | 113 else |
| 105 NOTREACHED(); | 114 NOTREACHED(); |
| 106 } | 115 } |
| 107 | 116 |
| 108 virtual void OnLogMessage(int host_id, | 117 virtual void OnLogMessage(int host_id, |
| 109 appcache::LogLevel log_level, | 118 appcache::LogLevel log_level, |
| 110 const std::string& message) { | 119 const std::string& message) { |
| 111 if (!system_) | 120 if (!system_) |
| 112 return; | 121 return; |
| 113 if (system_->is_io_thread()) | 122 if (system_->is_io_thread()) |
| 114 system_->ui_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 123 system_->ui_message_loop()->PostTask( |
| 115 this, &SimpleFrontendProxy::OnLogMessage, | 124 FROM_HERE, |
| 116 host_id, log_level, message)); | 125 base::Bind(&SimpleFrontendProxy::OnLogMessage, this, host_id, |
| 126 log_level, message)); |
| 117 else if (system_->is_ui_thread()) | 127 else if (system_->is_ui_thread()) |
| 118 system_->frontend_impl_.OnLogMessage( | 128 system_->frontend_impl_.OnLogMessage( |
| 119 host_id, log_level, message); | 129 host_id, log_level, message); |
| 120 else | 130 else |
| 121 NOTREACHED(); | 131 NOTREACHED(); |
| 122 } | 132 } |
| 123 | 133 |
| 124 virtual void OnContentBlocked(int host_id, const GURL& manifest_url) {} | 134 virtual void OnContentBlocked(int host_id, const GURL& manifest_url) {} |
| 125 | 135 |
| 126 private: | 136 private: |
| 127 friend class base::RefCountedThreadSafe<SimpleFrontendProxy>; | 137 friend class base::RefCountedThreadSafe<SimpleFrontendProxy>; |
| 128 | 138 |
| 129 ~SimpleFrontendProxy() {} | 139 ~SimpleFrontendProxy() {} |
| 130 | 140 |
| 131 SimpleAppCacheSystem* system_; | 141 SimpleAppCacheSystem* system_; |
| 132 }; | 142 }; |
| 133 | 143 |
| 134 | 144 |
| 135 // SimpleBackendProxy -------------------------------------------------------- | 145 // SimpleBackendProxy -------------------------------------------------------- |
| 136 // Proxies method calls from the frontend UI thread to the backend IO thread. | 146 // Proxies method calls from the frontend UI thread to the backend IO thread. |
| 137 | 147 |
| 138 class SimpleBackendProxy | 148 class SimpleBackendProxy |
| 139 : public base::RefCountedThreadSafe<SimpleBackendProxy>, | 149 : public base::RefCountedThreadSafe<SimpleBackendProxy>, |
| 140 public appcache::AppCacheBackend { | 150 public appcache::AppCacheBackend { |
| 141 public: | 151 public: |
| 142 explicit SimpleBackendProxy(SimpleAppCacheSystem* appcache_system) | 152 explicit SimpleBackendProxy(SimpleAppCacheSystem* appcache_system) |
| 143 : system_(appcache_system), event_(true, false) { | 153 : system_(appcache_system), event_(true, false) { |
| 144 get_status_callback_.reset( | 154 get_status_callback_ = |
| 145 NewCallback(this, &SimpleBackendProxy::GetStatusCallback)); | 155 base::Bind(&SimpleBackendProxy::GetStatusCallback, |
| 146 start_update_callback_.reset( | 156 base::Unretained(this)); |
| 147 NewCallback(this, &SimpleBackendProxy::StartUpdateCallback)); | 157 start_update_callback_ = |
| 148 swap_cache_callback_.reset( | 158 base::Bind(&SimpleBackendProxy::StartUpdateCallback, |
| 149 NewCallback(this, &SimpleBackendProxy::SwapCacheCallback)); | 159 base::Unretained(this)); |
| 160 swap_cache_callback_= |
| 161 base::Bind(&SimpleBackendProxy::SwapCacheCallback, |
| 162 base::Unretained(this)); |
| 150 } | 163 } |
| 151 | 164 |
| 152 virtual void RegisterHost(int host_id) { | 165 virtual void RegisterHost(int host_id) { |
| 153 if (system_->is_ui_thread()) { | 166 if (system_->is_ui_thread()) { |
| 154 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 167 system_->io_message_loop()->PostTask( |
| 155 this, &SimpleBackendProxy::RegisterHost, host_id)); | 168 FROM_HERE, |
| 169 base::Bind(&SimpleBackendProxy::RegisterHost, this, host_id)); |
| 156 } else if (system_->is_io_thread()) { | 170 } else if (system_->is_io_thread()) { |
| 157 system_->backend_impl_->RegisterHost(host_id); | 171 system_->backend_impl_->RegisterHost(host_id); |
| 158 } else { | 172 } else { |
| 159 NOTREACHED(); | 173 NOTREACHED(); |
| 160 } | 174 } |
| 161 } | 175 } |
| 162 | 176 |
| 163 virtual void UnregisterHost(int host_id) { | 177 virtual void UnregisterHost(int host_id) { |
| 164 if (system_->is_ui_thread()) { | 178 if (system_->is_ui_thread()) { |
| 165 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 179 system_->io_message_loop()->PostTask( |
| 166 this, &SimpleBackendProxy::UnregisterHost, host_id)); | 180 FROM_HERE, |
| 181 base::Bind(&SimpleBackendProxy::UnregisterHost, this, host_id)); |
| 167 } else if (system_->is_io_thread()) { | 182 } else if (system_->is_io_thread()) { |
| 168 system_->backend_impl_->UnregisterHost(host_id); | 183 system_->backend_impl_->UnregisterHost(host_id); |
| 169 } else { | 184 } else { |
| 170 NOTREACHED(); | 185 NOTREACHED(); |
| 171 } | 186 } |
| 172 } | 187 } |
| 173 | 188 |
| 174 virtual void SetSpawningHostId(int host_id, int spawning_host_id) { | 189 virtual void SetSpawningHostId(int host_id, int spawning_host_id) { |
| 175 if (system_->is_ui_thread()) { | 190 if (system_->is_ui_thread()) { |
| 176 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 191 system_->io_message_loop()->PostTask( |
| 177 this, &SimpleBackendProxy::SetSpawningHostId, | 192 FROM_HERE, |
| 178 host_id, spawning_host_id)); | 193 base::Bind(&SimpleBackendProxy::SetSpawningHostId, this, host_id, |
| 194 spawning_host_id)); |
| 179 } else if (system_->is_io_thread()) { | 195 } else if (system_->is_io_thread()) { |
| 180 system_->backend_impl_->SetSpawningHostId(host_id, spawning_host_id); | 196 system_->backend_impl_->SetSpawningHostId(host_id, spawning_host_id); |
| 181 } else { | 197 } else { |
| 182 NOTREACHED(); | 198 NOTREACHED(); |
| 183 } | 199 } |
| 184 } | 200 } |
| 185 | 201 |
| 186 virtual void SelectCache(int host_id, | 202 virtual void SelectCache(int host_id, |
| 187 const GURL& document_url, | 203 const GURL& document_url, |
| 188 const int64 cache_document_was_loaded_from, | 204 const int64 cache_document_was_loaded_from, |
| 189 const GURL& manifest_url) { | 205 const GURL& manifest_url) { |
| 190 if (system_->is_ui_thread()) { | 206 if (system_->is_ui_thread()) { |
| 191 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 207 system_->io_message_loop()->PostTask( |
| 192 this, &SimpleBackendProxy::SelectCache, host_id, document_url, | 208 FROM_HERE, |
| 193 cache_document_was_loaded_from, manifest_url)); | 209 base::Bind(&SimpleBackendProxy::SelectCache, this, host_id, |
| 210 document_url, cache_document_was_loaded_from, |
| 211 manifest_url)); |
| 194 } else if (system_->is_io_thread()) { | 212 } else if (system_->is_io_thread()) { |
| 195 system_->backend_impl_->SelectCache(host_id, document_url, | 213 system_->backend_impl_->SelectCache(host_id, document_url, |
| 196 cache_document_was_loaded_from, | 214 cache_document_was_loaded_from, |
| 197 manifest_url); | 215 manifest_url); |
| 198 } else { | 216 } else { |
| 199 NOTREACHED(); | 217 NOTREACHED(); |
| 200 } | 218 } |
| 201 } | 219 } |
| 202 | 220 |
| 203 virtual void GetResourceList( | 221 virtual void GetResourceList( |
| 204 int host_id, | 222 int host_id, |
| 205 std::vector<appcache::AppCacheResourceInfo>* resource_infos) { | 223 std::vector<appcache::AppCacheResourceInfo>* resource_infos) { |
| 206 if (system_->is_ui_thread()) { | 224 if (system_->is_ui_thread()) { |
| 207 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 225 system_->io_message_loop()->PostTask( |
| 208 this, &SimpleBackendProxy::GetResourceList, | 226 FROM_HERE, |
| 209 host_id, resource_infos)); | 227 base::Bind(&SimpleBackendProxy::GetResourceList, this, host_id, |
| 228 resource_infos)); |
| 210 } else if (system_->is_io_thread()) { | 229 } else if (system_->is_io_thread()) { |
| 211 system_->backend_impl_->GetResourceList(host_id, resource_infos); | 230 system_->backend_impl_->GetResourceList(host_id, resource_infos); |
| 212 } else { | 231 } else { |
| 213 NOTREACHED(); | 232 NOTREACHED(); |
| 214 } | 233 } |
| 215 } | 234 } |
| 216 | 235 |
| 217 virtual void SelectCacheForWorker( | 236 virtual void SelectCacheForWorker( |
| 218 int host_id, | 237 int host_id, |
| 219 int parent_process_id, | 238 int parent_process_id, |
| 220 int parent_host_id) { | 239 int parent_host_id) { |
| 221 NOTIMPLEMENTED(); // Workers are not supported in test_shell. | 240 NOTIMPLEMENTED(); // Workers are not supported in test_shell. |
| 222 } | 241 } |
| 223 | 242 |
| 224 virtual void SelectCacheForSharedWorker( | 243 virtual void SelectCacheForSharedWorker( |
| 225 int host_id, | 244 int host_id, |
| 226 int64 appcache_id) { | 245 int64 appcache_id) { |
| 227 NOTIMPLEMENTED(); // Workers are not supported in test_shell. | 246 NOTIMPLEMENTED(); // Workers are not supported in test_shell. |
| 228 } | 247 } |
| 229 | 248 |
| 230 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, | 249 virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, |
| 231 int64 cache_document_was_loaded_from) { | 250 int64 cache_document_was_loaded_from) { |
| 232 if (system_->is_ui_thread()) { | 251 if (system_->is_ui_thread()) { |
| 233 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 252 system_->io_message_loop()->PostTask( |
| 234 this, &SimpleBackendProxy::MarkAsForeignEntry, host_id, document_url, | 253 FROM_HERE, |
| 235 cache_document_was_loaded_from)); | 254 base::Bind(&SimpleBackendProxy::MarkAsForeignEntry, this, host_id, |
| 255 document_url, cache_document_was_loaded_from)); |
| 236 } else if (system_->is_io_thread()) { | 256 } else if (system_->is_io_thread()) { |
| 237 system_->backend_impl_->MarkAsForeignEntry( | 257 system_->backend_impl_->MarkAsForeignEntry( |
| 238 host_id, document_url, | 258 host_id, document_url, |
| 239 cache_document_was_loaded_from); | 259 cache_document_was_loaded_from); |
| 240 } else { | 260 } else { |
| 241 NOTREACHED(); | 261 NOTREACHED(); |
| 242 } | 262 } |
| 243 } | 263 } |
| 244 | 264 |
| 245 virtual appcache::Status GetStatus(int host_id) { | 265 virtual appcache::Status GetStatus(int host_id) { |
| 246 if (system_->is_ui_thread()) { | 266 if (system_->is_ui_thread()) { |
| 247 status_result_ = appcache::UNCACHED; | 267 status_result_ = appcache::UNCACHED; |
| 248 event_.Reset(); | 268 event_.Reset(); |
| 249 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 269 system_->io_message_loop()->PostTask( |
| 250 this, &SimpleBackendProxy::GetStatus, host_id)); | 270 FROM_HERE, |
| 271 NewRunnableMethod(this, &SimpleBackendProxy::GetStatus, host_id)); |
| 251 event_.Wait(); | 272 event_.Wait(); |
| 252 } else if (system_->is_io_thread()) { | 273 } else if (system_->is_io_thread()) { |
| 253 system_->backend_impl_->GetStatusWithCallback( | 274 system_->backend_impl_->GetStatusWithCallback( |
| 254 host_id, get_status_callback_.get(), NULL); | 275 host_id, get_status_callback_, NULL); |
| 255 } else { | 276 } else { |
| 256 NOTREACHED(); | 277 NOTREACHED(); |
| 257 } | 278 } |
| 258 return status_result_; | 279 return status_result_; |
| 259 } | 280 } |
| 260 | 281 |
| 261 virtual bool StartUpdate(int host_id) { | 282 virtual bool StartUpdate(int host_id) { |
| 262 if (system_->is_ui_thread()) { | 283 if (system_->is_ui_thread()) { |
| 263 bool_result_ = false; | 284 bool_result_ = false; |
| 264 event_.Reset(); | 285 event_.Reset(); |
| 265 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 286 system_->io_message_loop()->PostTask( |
| 266 this, &SimpleBackendProxy::StartUpdate, host_id)); | 287 FROM_HERE, |
| 288 NewRunnableMethod(this, &SimpleBackendProxy::StartUpdate, host_id)); |
| 267 event_.Wait(); | 289 event_.Wait(); |
| 268 } else if (system_->is_io_thread()) { | 290 } else if (system_->is_io_thread()) { |
| 269 system_->backend_impl_->StartUpdateWithCallback( | 291 system_->backend_impl_->StartUpdateWithCallback( |
| 270 host_id, start_update_callback_.get(), NULL); | 292 host_id, start_update_callback_, NULL); |
| 271 } else { | 293 } else { |
| 272 NOTREACHED(); | 294 NOTREACHED(); |
| 273 } | 295 } |
| 274 return bool_result_; | 296 return bool_result_; |
| 275 } | 297 } |
| 276 | 298 |
| 277 virtual bool SwapCache(int host_id) { | 299 virtual bool SwapCache(int host_id) { |
| 278 if (system_->is_ui_thread()) { | 300 if (system_->is_ui_thread()) { |
| 279 bool_result_ = false; | 301 bool_result_ = false; |
| 280 event_.Reset(); | 302 event_.Reset(); |
| 281 system_->io_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 303 system_->io_message_loop()->PostTask( |
| 282 this, &SimpleBackendProxy::SwapCache, host_id)); | 304 FROM_HERE, |
| 305 NewRunnableMethod(this, &SimpleBackendProxy::SwapCache, host_id)); |
| 283 event_.Wait(); | 306 event_.Wait(); |
| 284 } else if (system_->is_io_thread()) { | 307 } else if (system_->is_io_thread()) { |
| 285 system_->backend_impl_->SwapCacheWithCallback( | 308 system_->backend_impl_->SwapCacheWithCallback( |
| 286 host_id, swap_cache_callback_.get(), NULL); | 309 host_id, swap_cache_callback_, NULL); |
| 287 } else { | 310 } else { |
| 288 NOTREACHED(); | 311 NOTREACHED(); |
| 289 } | 312 } |
| 290 return bool_result_; | 313 return bool_result_; |
| 291 } | 314 } |
| 292 | 315 |
| 293 void GetStatusCallback(appcache::Status status, void* param) { | 316 void GetStatusCallback(appcache::Status status, void* param) { |
| 294 status_result_ = status; | 317 status_result_ = status; |
| 295 event_.Signal(); | 318 event_.Signal(); |
| 296 } | 319 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 311 | 334 |
| 312 private: | 335 private: |
| 313 friend class base::RefCountedThreadSafe<SimpleBackendProxy>; | 336 friend class base::RefCountedThreadSafe<SimpleBackendProxy>; |
| 314 | 337 |
| 315 ~SimpleBackendProxy() {} | 338 ~SimpleBackendProxy() {} |
| 316 | 339 |
| 317 SimpleAppCacheSystem* system_; | 340 SimpleAppCacheSystem* system_; |
| 318 base::WaitableEvent event_; | 341 base::WaitableEvent event_; |
| 319 bool bool_result_; | 342 bool bool_result_; |
| 320 appcache::Status status_result_; | 343 appcache::Status status_result_; |
| 321 scoped_ptr<appcache::GetStatusCallback> get_status_callback_; | 344 appcache::GetStatusCallback get_status_callback_; |
| 322 scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; | 345 appcache::StartUpdateCallback start_update_callback_; |
| 323 scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; | 346 appcache::SwapCacheCallback swap_cache_callback_; |
| 324 }; | 347 }; |
| 325 | 348 |
| 326 | 349 |
| 327 // SimpleAppCacheSystem -------------------------------------------------------- | 350 // SimpleAppCacheSystem -------------------------------------------------------- |
| 328 | 351 |
| 329 // This class only works for a single process browser. | 352 // This class only works for a single process browser. |
| 330 static const int kSingleProcessId = 1; | 353 static const int kSingleProcessId = 1; |
| 331 | 354 |
| 332 // A not so thread safe singleton, but should work for test_shell. | 355 // A not so thread safe singleton, but should work for test_shell. |
| 333 SimpleAppCacheSystem* SimpleAppCacheSystem::instance_ = NULL; | 356 SimpleAppCacheSystem* SimpleAppCacheSystem::instance_ = NULL; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 349 | 372 |
| 350 SimpleAppCacheSystem::~SimpleAppCacheSystem() { | 373 SimpleAppCacheSystem::~SimpleAppCacheSystem() { |
| 351 DCHECK(!io_message_loop_ && !backend_impl_ && !service_); | 374 DCHECK(!io_message_loop_ && !backend_impl_ && !service_); |
| 352 frontend_proxy_->clear_appcache_system(); // in case a task is in transit | 375 frontend_proxy_->clear_appcache_system(); // in case a task is in transit |
| 353 instance_ = NULL; | 376 instance_ = NULL; |
| 354 | 377 |
| 355 if (db_thread_.IsRunning()) { | 378 if (db_thread_.IsRunning()) { |
| 356 // We pump a task thru the db thread to ensure any tasks previously | 379 // We pump a task thru the db thread to ensure any tasks previously |
| 357 // scheduled on that thread have been performed prior to return. | 380 // scheduled on that thread have been performed prior to return. |
| 358 base::WaitableEvent event(false, false); | 381 base::WaitableEvent event(false, false); |
| 359 db_thread_.message_loop()->PostTask(FROM_HERE, | 382 db_thread_.message_loop()->PostTask( |
| 360 NewRunnableFunction(&SignalEvent, &event)); | 383 FROM_HERE, base::Bind(&SignalEvent, &event)); |
| 361 event.Wait(); | 384 event.Wait(); |
| 362 } | 385 } |
| 363 } | 386 } |
| 364 | 387 |
| 365 void SimpleAppCacheSystem::InitOnUIThread(const FilePath& cache_directory) { | 388 void SimpleAppCacheSystem::InitOnUIThread(const FilePath& cache_directory) { |
| 366 DCHECK(!ui_message_loop_); | 389 DCHECK(!ui_message_loop_); |
| 367 ui_message_loop_ = MessageLoop::current(); | 390 ui_message_loop_ = MessageLoop::current(); |
| 368 cache_directory_ = cache_directory; | 391 cache_directory_ = cache_directory; |
| 369 } | 392 } |
| 370 | 393 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 452 } |
| 430 | 453 |
| 431 void SimpleAppCacheSystem::GetExtraResponseBits( | 454 void SimpleAppCacheSystem::GetExtraResponseBits( |
| 432 net::URLRequest* request, int64* cache_id, GURL* manifest_url) { | 455 net::URLRequest* request, int64* cache_id, GURL* manifest_url) { |
| 433 if (is_initialized()) { | 456 if (is_initialized()) { |
| 434 DCHECK(is_io_thread()); | 457 DCHECK(is_io_thread()); |
| 435 AppCacheInterceptor::GetExtraResponseInfo( | 458 AppCacheInterceptor::GetExtraResponseInfo( |
| 436 request, cache_id, manifest_url); | 459 request, cache_id, manifest_url); |
| 437 } | 460 } |
| 438 } | 461 } |
| OLD | NEW |