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/appcache/appcache_service.h" | 5 #include "webkit/appcache/appcache_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 protected: | 58 protected: |
59 void CallCallback(int rv) { | 59 void CallCallback(int rv) { |
60 if (!callback_.is_null()) { | 60 if (!callback_.is_null()) { |
61 // Defer to guarantee async completion. | 61 // Defer to guarantee async completion. |
62 MessageLoop::current()->PostTask( | 62 MessageLoop::current()->PostTask( |
63 FROM_HERE, base::Bind(&DeferredCallback, callback_, rv)); | 63 FROM_HERE, base::Bind(&DeferredCallback, callback_, rv)); |
64 } | 64 } |
65 callback_.Reset(); | 65 callback_.Reset(); |
66 } | 66 } |
67 | 67 |
68 static void DeferredCallCallback(const net::CompletionCallback& callback, | |
69 int rv) { | |
70 callback.Run(rv); | |
71 } | |
72 | |
73 AppCacheService* service_; | 68 AppCacheService* service_; |
74 net::CompletionCallback callback_; | 69 net::CompletionCallback callback_; |
75 }; | 70 }; |
76 | 71 |
77 void AppCacheService::NewAsyncHelper::Cancel() { | 72 void AppCacheService::NewAsyncHelper::Cancel() { |
78 if (!callback_.is_null()) { | 73 if (!callback_.is_null()) { |
79 callback_.Run(net::ERR_ABORTED); | 74 callback_.Run(net::ERR_ABORTED); |
80 callback_.Reset(); | 75 callback_.Reset(); |
81 } | 76 } |
82 | 77 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 backends_.insert( | 551 backends_.insert( |
557 BackendMap::value_type(backend_impl->process_id(), backend_impl)); | 552 BackendMap::value_type(backend_impl->process_id(), backend_impl)); |
558 } | 553 } |
559 | 554 |
560 void AppCacheService::UnregisterBackend( | 555 void AppCacheService::UnregisterBackend( |
561 AppCacheBackendImpl* backend_impl) { | 556 AppCacheBackendImpl* backend_impl) { |
562 backends_.erase(backend_impl->process_id()); | 557 backends_.erase(backend_impl->process_id()); |
563 } | 558 } |
564 | 559 |
565 } // namespace appcache | 560 } // namespace appcache |
OLD | NEW |