Chromium Code Reviews| 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_response.h" | 5 #include "webkit/appcache/appcache_response.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/pickle.h" | 10 #include "base/pickle.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 13 #include "webkit/appcache/appcache_service.h" | 14 #include "webkit/appcache/appcache_service.h" |
| 14 | 15 |
| 15 namespace appcache { | 16 namespace appcache { |
| 16 | 17 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 : http_info(info), response_data_size(kUnkownResponseDataSize) {} | 69 : http_info(info), response_data_size(kUnkownResponseDataSize) {} |
| 69 | 70 |
| 70 HttpResponseInfoIOBuffer::~HttpResponseInfoIOBuffer() {} | 71 HttpResponseInfoIOBuffer::~HttpResponseInfoIOBuffer() {} |
| 71 | 72 |
| 72 // AppCacheResponseIO ---------------------------------------------- | 73 // AppCacheResponseIO ---------------------------------------------- |
| 73 | 74 |
| 74 AppCacheResponseIO::AppCacheResponseIO( | 75 AppCacheResponseIO::AppCacheResponseIO( |
| 75 int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache) | 76 int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache) |
| 76 : response_id_(response_id), group_id_(group_id), disk_cache_(disk_cache), | 77 : response_id_(response_id), group_id_(group_id), disk_cache_(disk_cache), |
| 77 entry_(NULL), buffer_len_(0), user_callback_(NULL), | 78 entry_(NULL), buffer_len_(0), user_callback_(NULL), |
| 78 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), | 79 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 79 ALLOW_THIS_IN_INITIALIZER_LIST(raw_callback_( | 80 ALLOW_THIS_IN_INITIALIZER_LIST(raw_callback_( |
| 80 new net::CancelableOldCompletionCallback<AppCacheResponseIO>( | 81 new net::CancelableOldCompletionCallback<AppCacheResponseIO>( |
| 81 this, &AppCacheResponseIO::OnRawIOComplete))) { | 82 this, &AppCacheResponseIO::OnRawIOComplete))) { |
| 82 } | 83 } |
| 83 | 84 |
| 84 AppCacheResponseIO::~AppCacheResponseIO() { | 85 AppCacheResponseIO::~AppCacheResponseIO() { |
| 85 raw_callback_->Cancel(); | 86 raw_callback_->Cancel(); |
| 86 if (entry_) | 87 if (entry_) |
| 87 entry_->Close(); | 88 entry_->Close(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void AppCacheResponseIO::ScheduleIOOldCompletionCallback(int result) { | 91 void AppCacheResponseIO::ScheduleIOOldCompletionCallback(int result) { |
| 91 MessageLoop::current()->PostTask(FROM_HERE, | 92 MessageLoop::current()->PostTask(FROM_HERE, |
|
James Hawkins
2011/10/27 03:30:32
nit: Parameters must start on the same column. In
michaeln
2011/10/27 19:20:02
Done.
| |
| 92 method_factory_.NewRunnableMethod( | 93 base::Bind(&AppCacheResponseIO::OnIOComplete, |
| 93 &AppCacheResponseIO::OnIOComplete, result)); | 94 weak_factory_.GetWeakPtr(), result)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void AppCacheResponseIO::InvokeUserOldCompletionCallback(int result) { | 97 void AppCacheResponseIO::InvokeUserOldCompletionCallback(int result) { |
| 97 // Clear the user callback and buffers prior to invoking the callback | 98 // Clear the user callback and buffers prior to invoking the callback |
| 98 // so the caller can schedule additional operations in the callback. | 99 // so the caller can schedule additional operations in the callback. |
| 99 buffer_ = NULL; | 100 buffer_ = NULL; |
| 100 info_buffer_ = NULL; | 101 info_buffer_ = NULL; |
| 101 net::OldCompletionCallback* temp_user_callback = user_callback_; | 102 net::OldCompletionCallback* temp_user_callback = user_callback_; |
| 102 user_callback_ = NULL; | 103 user_callback_ = NULL; |
| 103 temp_user_callback->Run(result); | 104 temp_user_callback->Run(result); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 } | 388 } |
| 388 | 389 |
| 389 if (info_buffer_) | 390 if (info_buffer_) |
| 390 ContinueWriteInfo(); | 391 ContinueWriteInfo(); |
| 391 else | 392 else |
| 392 ContinueWriteData(); | 393 ContinueWriteData(); |
| 393 } | 394 } |
| 394 | 395 |
| 395 } // namespace appcache | 396 } // namespace appcache |
| 396 | 397 |
| OLD | NEW |