Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 2055053003: [BlobAsync] Disk support for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finished comments, added new pending enum state Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker/service_worker_url_request_job.h" 5 #include "content/browser/service_worker/service_worker_url_request_job.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 } 152 }
153 153
154 if (num_pending_request_body_blobs_ == 0) 154 if (num_pending_request_body_blobs_ == 0)
155 Complete(true); 155 Complete(true);
156 } 156 }
157 157
158 private: 158 private:
159 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL }; 159 enum class Phase { INITIAL, WAITING, SUCCESS, FAIL };
160 160
161 void OneRequestBodyBlobCompleted( 161 void OneRequestBodyBlobCompleted(storage::BlobStatus status) {
162 bool success,
163 storage::IPCBlobCreationCancelCode cancel_code) {
164 DCHECK_GT(num_pending_request_body_blobs_, 0UL); 162 DCHECK_GT(num_pending_request_body_blobs_, 0UL);
165 163
166 if (success) 164 bool error = storage::BlobStatusIsError(status);
165 if (!error)
167 --num_pending_request_body_blobs_; 166 --num_pending_request_body_blobs_;
168 else 167 else
169 num_pending_request_body_blobs_ = 0; 168 num_pending_request_body_blobs_ = 0;
170 169
171 if (num_pending_request_body_blobs_ == 0) 170 if (num_pending_request_body_blobs_ == 0)
172 Complete(success); 171 Complete(error);
173 } 172 }
174 173
175 void Complete(bool success) { 174 void Complete(bool success) {
176 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_)); 175 DCHECK_EQ(static_cast<int>(Phase::WAITING), static_cast<int>(phase_));
177 phase_ = success ? Phase::SUCCESS : Phase::FAIL; 176 phase_ = success ? Phase::SUCCESS : Phase::FAIL;
178 // Destroys |this|. 177 // Destroys |this|.
179 callback_.Run(success); 178 callback_.Run(success);
180 } 179 }
181 180
182 // Owns and must outlive |this|. 181 // Owns and must outlive |this|.
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(), 1037 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(),
1039 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, 1038 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent,
1040 weak_factory_.GetWeakPtr(), active_worker), 1039 weak_factory_.GetWeakPtr(), active_worker),
1041 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, 1040 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent,
1042 weak_factory_.GetWeakPtr()))); 1041 weak_factory_.GetWeakPtr())));
1043 worker_start_time_ = base::TimeTicks::Now(); 1042 worker_start_time_ = base::TimeTicks::Now();
1044 fetch_dispatcher_->Run(); 1043 fetch_dispatcher_->Run();
1045 } 1044 }
1046 1045
1047 } // namespace content 1046 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698