| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_storage.h" | 5 #include "webkit/appcache/appcache_storage.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 7 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 8 #include "webkit/appcache/appcache_response.h" | 10 #include "webkit/appcache/appcache_response.h" |
| 9 #include "webkit/appcache/appcache_service.h" | 11 #include "webkit/appcache/appcache_service.h" |
| 10 #include "webkit/quota/quota_client.h" | 12 #include "webkit/quota/quota_client.h" |
| 11 #include "webkit/quota/quota_manager.h" | 13 #include "webkit/quota/quota_manager.h" |
| 12 | 14 |
| 13 namespace appcache { | 15 namespace appcache { |
| 14 | 16 |
| 15 // static | 17 // static |
| 16 const int64 AppCacheStorage::kUnitializedId = -1; | 18 const int64 AppCacheStorage::kUnitializedId = -1; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 39 | 41 |
| 40 AppCacheStorage::ResponseInfoLoadTask::ResponseInfoLoadTask( | 42 AppCacheStorage::ResponseInfoLoadTask::ResponseInfoLoadTask( |
| 41 const GURL& manifest_url, | 43 const GURL& manifest_url, |
| 42 int64 group_id, | 44 int64 group_id, |
| 43 int64 response_id, | 45 int64 response_id, |
| 44 AppCacheStorage* storage) | 46 AppCacheStorage* storage) |
| 45 : storage_(storage), | 47 : storage_(storage), |
| 46 manifest_url_(manifest_url), | 48 manifest_url_(manifest_url), |
| 47 group_id_(group_id), | 49 group_id_(group_id), |
| 48 response_id_(response_id), | 50 response_id_(response_id), |
| 49 info_buffer_(new HttpResponseInfoIOBuffer), | 51 info_buffer_(new HttpResponseInfoIOBuffer) { |
| 50 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( | |
| 51 this, &ResponseInfoLoadTask::OnReadComplete)) { | |
| 52 storage_->pending_info_loads_.insert( | 52 storage_->pending_info_loads_.insert( |
| 53 PendingResponseInfoLoads::value_type(response_id, this)); | 53 PendingResponseInfoLoads::value_type(response_id, this)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 AppCacheStorage::ResponseInfoLoadTask::~ResponseInfoLoadTask() { | 56 AppCacheStorage::ResponseInfoLoadTask::~ResponseInfoLoadTask() { |
| 57 } | 57 } |
| 58 | 58 |
| 59 void AppCacheStorage::ResponseInfoLoadTask::StartIfNeeded() { | 59 void AppCacheStorage::ResponseInfoLoadTask::StartIfNeeded() { |
| 60 if (reader_.get()) | 60 if (reader_.get()) |
| 61 return; | 61 return; |
| 62 reader_.reset( | 62 reader_.reset( |
| 63 storage_->CreateResponseReader(manifest_url_, group_id_, response_id_)); | 63 storage_->CreateResponseReader(manifest_url_, group_id_, response_id_)); |
| 64 reader_->ReadInfo(info_buffer_, &read_callback_); | 64 reader_->ReadInfo( |
| 65 info_buffer_, base::Bind(&ResponseInfoLoadTask::OnReadComplete, |
| 66 base::Unretained(this))); |
| 65 } | 67 } |
| 66 | 68 |
| 67 void AppCacheStorage::ResponseInfoLoadTask::OnReadComplete(int result) { | 69 void AppCacheStorage::ResponseInfoLoadTask::OnReadComplete(int result) { |
| 68 storage_->pending_info_loads_.erase(response_id_); | 70 storage_->pending_info_loads_.erase(response_id_); |
| 69 scoped_refptr<AppCacheResponseInfo> info; | 71 scoped_refptr<AppCacheResponseInfo> info; |
| 70 if (result >= 0) { | 72 if (result >= 0) { |
| 71 info = new AppCacheResponseInfo(storage_->service(), manifest_url_, | 73 info = new AppCacheResponseInfo(storage_->service(), manifest_url_, |
| 72 response_id_, | 74 response_id_, |
| 73 info_buffer_->http_info.release(), | 75 info_buffer_->http_info.release(), |
| 74 info_buffer_->response_data_size); | 76 info_buffer_->response_data_size); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void AppCacheStorage::NotifyStorageAccessed(const GURL& origin) { | 127 void AppCacheStorage::NotifyStorageAccessed(const GURL& origin) { |
| 126 if (service()->quota_manager_proxy() && | 128 if (service()->quota_manager_proxy() && |
| 127 usage_map_.find(origin) != usage_map_.end()) | 129 usage_map_.find(origin) != usage_map_.end()) |
| 128 service()->quota_manager_proxy()->NotifyStorageAccessed( | 130 service()->quota_manager_proxy()->NotifyStorageAccessed( |
| 129 quota::QuotaClient::kAppcache, | 131 quota::QuotaClient::kAppcache, |
| 130 origin, quota::kStorageTypeTemporary); | 132 origin, quota::kStorageTypeTemporary); |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace appcache | 135 } // namespace appcache |
| 134 | 136 |
| OLD | NEW |