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

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

Issue 2689693003: Add a helper method to create SW SimpleEventCallbacks. (Closed)
Patch Set: Created 3 years, 10 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 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/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 external_request_uuid_to_request_id_.erase(iter); 611 external_request_uuid_to_request_id_.erase(iter);
612 return FinishRequest(request_id, true, base::Time::Now()); 612 return FinishRequest(request_id, true, base::Time::Now());
613 } 613 }
614 614
615 // It is possible that the request was cancelled or timed out before and we 615 // It is possible that the request was cancelled or timed out before and we
616 // won't find it in |external_request_uuid_to_request_id_|. 616 // won't find it in |external_request_uuid_to_request_id_|.
617 // Return true so we don't kill the process. 617 // Return true so we don't kill the process.
618 return true; 618 return true;
619 } 619 }
620 620
621 ServiceWorkerVersion::SimpleEventCallback
622 ServiceWorkerVersion::CreateSimpleEventCallback(int request_id) {
623 // The weak reference to |this| is safe because storage of the callbacks, the
624 // pending responses of the ServiceWorkerEventDispatcher, is owned by |this|.
625 return base::Bind(&ServiceWorkerVersion::OnSimpleEventFinished,
626 base::Unretained(this), request_id);
627 }
628
621 void ServiceWorkerVersion::RunAfterStartWorker( 629 void ServiceWorkerVersion::RunAfterStartWorker(
622 ServiceWorkerMetrics::EventType purpose, 630 ServiceWorkerMetrics::EventType purpose,
623 const base::Closure& task, 631 const base::Closure& task,
624 const StatusCallback& error_callback) { 632 const StatusCallback& error_callback) {
625 if (running_status() == EmbeddedWorkerStatus::RUNNING) { 633 if (running_status() == EmbeddedWorkerStatus::RUNNING) {
626 DCHECK(start_callbacks_.empty()); 634 DCHECK(start_callbacks_.empty());
627 task.Run(); 635 task.Run();
628 return; 636 return;
629 } 637 }
630 StartWorker(purpose, 638 StartWorker(purpose,
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 1895
1888 void ServiceWorkerVersion::CleanUpExternalRequest( 1896 void ServiceWorkerVersion::CleanUpExternalRequest(
1889 const std::string& request_uuid, 1897 const std::string& request_uuid,
1890 ServiceWorkerStatusCode status) { 1898 ServiceWorkerStatusCode status) {
1891 if (status == SERVICE_WORKER_OK) 1899 if (status == SERVICE_WORKER_OK)
1892 return; 1900 return;
1893 external_request_uuid_to_request_id_.erase(request_uuid); 1901 external_request_uuid_to_request_id_.erase(request_uuid);
1894 } 1902 }
1895 1903
1896 } // namespace content 1904 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698