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

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

Powered by Google App Engine
This is Rietveld 408576698