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/logging.h" | 8 #include "base/logging.h" |
8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
10 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
11 #include "webkit/appcache/appcache.h" | 12 #include "webkit/appcache/appcache.h" |
12 #include "webkit/appcache/appcache_backend_impl.h" | 13 #include "webkit/appcache/appcache_backend_impl.h" |
13 #include "webkit/appcache/appcache_entry.h" | 14 #include "webkit/appcache/appcache_entry.h" |
14 #include "webkit/appcache/appcache_histograms.h" | 15 #include "webkit/appcache/appcache_histograms.h" |
15 #include "webkit/appcache/appcache_policy.h" | 16 #include "webkit/appcache/appcache_policy.h" |
16 #include "webkit/appcache/appcache_quota_client.h" | 17 #include "webkit/appcache/appcache_quota_client.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
43 | 44 |
44 virtual void Start() = 0; | 45 virtual void Start() = 0; |
45 virtual void Cancel(); | 46 virtual void Cancel(); |
46 | 47 |
47 protected: | 48 protected: |
48 void CallCallback(int rv) { | 49 void CallCallback(int rv) { |
49 if (callback_) { | 50 if (callback_) { |
50 // Defer to guarentee async completion. | 51 // Defer to guarentee async completion. |
51 MessageLoop::current()->PostTask( | 52 MessageLoop::current()->PostTask( |
52 FROM_HERE, | 53 FROM_HERE, |
53 NewRunnableFunction(&DeferredCallCallback, callback_, rv)); | 54 base::Bind(&DeferredCallCallback, callback_, rv)); |
James Hawkins
2011/10/27 03:30:32
Nit: Looks like we can save a line and put this pa
michaeln
2011/10/27 19:20:02
Done.
| |
54 } | 55 } |
55 callback_ = NULL; | 56 callback_ = NULL; |
56 } | 57 } |
57 | 58 |
58 static void DeferredCallCallback(net::OldCompletionCallback* callback, int rv) { | 59 static void DeferredCallCallback(net::OldCompletionCallback* callback, int rv) { |
James Hawkins
2011/10/27 03:30:32
Nit: This was wrong from before, but this breaks 8
michaeln
2011/10/27 19:20:02
Done.
| |
59 callback->Run(rv); | 60 callback->Run(rv); |
60 } | 61 } |
61 | 62 |
62 AppCacheService* service_; | 63 AppCacheService* service_; |
63 net::OldCompletionCallback* callback_; | 64 net::OldCompletionCallback* callback_; |
64 }; | 65 }; |
65 | 66 |
66 void AppCacheService::AsyncHelper::Cancel() { | 67 void AppCacheService::AsyncHelper::Cancel() { |
67 if (callback_) { | 68 if (callback_) { |
68 callback_->Run(net::ERR_ABORTED); | 69 callback_->Run(net::ERR_ABORTED); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 backends_.insert( | 490 backends_.insert( |
490 BackendMap::value_type(backend_impl->process_id(), backend_impl)); | 491 BackendMap::value_type(backend_impl->process_id(), backend_impl)); |
491 } | 492 } |
492 | 493 |
493 void AppCacheService::UnregisterBackend( | 494 void AppCacheService::UnregisterBackend( |
494 AppCacheBackendImpl* backend_impl) { | 495 AppCacheBackendImpl* backend_impl) { |
495 backends_.erase(backend_impl->process_id()); | 496 backends_.erase(backend_impl->process_id()); |
496 } | 497 } |
497 | 498 |
498 } // namespace appcache | 499 } // namespace appcache |
OLD | NEW |