| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/pepper/quota_reservation.h" | 5 #include "content/browser/renderer_host/pepper/quota_reservation.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 10 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 callback)); | 114 callback)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void QuotaReservation::OnClientCrash() { | 117 void QuotaReservation::OnClientCrash() { |
| 118 quota_reservation_->OnClientCrash(); | 118 quota_reservation_->OnClientCrash(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void QuotaReservation::GotReservedQuota( | 121 void QuotaReservation::GotReservedQuota( |
| 122 const ReserveQuotaCallback& callback, | 122 const ReserveQuotaCallback& callback, |
| 123 base::File::Error error) { | 123 base::File::Error error) { |
| 124 ppapi::FileSizeMap max_written_offsets; | 124 ppapi::FileSizeMap file_sizes; |
| 125 for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) { | 125 for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) |
| 126 max_written_offsets.insert( | 126 file_sizes[it->first] = it->second->GetMaxWrittenOffset(); |
| 127 std::make_pair(it->first, it->second->GetMaxWrittenOffset())); | |
| 128 } | |
| 129 | 127 |
| 130 if (file_system_context_) { | 128 if (file_system_context_) { |
| 131 BrowserThread::PostTask( | 129 BrowserThread::PostTask( |
| 132 BrowserThread::IO, | 130 BrowserThread::IO, |
| 133 FROM_HERE, | 131 FROM_HERE, |
| 134 base::Bind(callback, | 132 base::Bind(callback, |
| 135 quota_reservation_->remaining_quota(), | 133 quota_reservation_->remaining_quota(), |
| 136 max_written_offsets)); | 134 file_sizes)); |
| 137 } else { | 135 } else { |
| 138 // Unit testing code path. | 136 // Unit testing code path. |
| 139 callback.Run(quota_reservation_->remaining_quota(), max_written_offsets); | 137 callback.Run(quota_reservation_->remaining_quota(), file_sizes); |
| 140 } | 138 } |
| 141 } | 139 } |
| 142 | 140 |
| 143 void QuotaReservation::DeleteOnCorrectThread() const { | 141 void QuotaReservation::DeleteOnCorrectThread() const { |
| 144 if (file_system_context_ && | 142 if (file_system_context_ && |
| 145 !file_system_context_-> | 143 !file_system_context_-> |
| 146 default_file_task_runner()->RunsTasksOnCurrentThread()) { | 144 default_file_task_runner()->RunsTasksOnCurrentThread()) { |
| 147 file_system_context_->default_file_task_runner()->DeleteSoon( | 145 file_system_context_->default_file_task_runner()->DeleteSoon( |
| 148 FROM_HERE, | 146 FROM_HERE, |
| 149 this); | 147 this); |
| 150 } else { | 148 } else { |
| 151 // We're on the right thread to delete, or unit test. | 149 // We're on the right thread to delete, or unit test. |
| 152 delete this; | 150 delete this; |
| 153 } | 151 } |
| 154 } | 152 } |
| 155 | 153 |
| 156 } // namespace content | 154 } // namespace content |
| OLD | NEW |