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

Side by Side Diff: content/browser/background_fetch/background_fetch_event_dispatcher.cc

Issue 2973233002: [Background Fetch] Cleanup/fix thread safety (Closed)
Patch Set: Remove n.b. from comments Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/background_fetch/background_fetch_event_dispatcher.h" 5 #include "content/browser/background_fetch/background_fetch_event_dispatcher.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 "base/metrics/histogram_functions.h" 9 #include "base/metrics/histogram_functions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // Used because the |histogram_name| is not a constant. 59 // Used because the |histogram_name| is not a constant.
60 base::UmaHistogramEnumeration(histogram_name, service_worker_status, 60 base::UmaHistogramEnumeration(histogram_name, service_worker_status,
61 SERVICE_WORKER_ERROR_MAX_VALUE); 61 SERVICE_WORKER_ERROR_MAX_VALUE);
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 BackgroundFetchEventDispatcher::BackgroundFetchEventDispatcher( 66 BackgroundFetchEventDispatcher::BackgroundFetchEventDispatcher(
67 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) 67 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context)
68 : service_worker_context_(service_worker_context) {} 68 : service_worker_context_(service_worker_context) {
69 // Constructed on the UI thread, then lives on the IO thread.
70 DCHECK_CURRENTLY_ON(BrowserThread::UI);
71 }
69 72
70 BackgroundFetchEventDispatcher::~BackgroundFetchEventDispatcher() = default; 73 BackgroundFetchEventDispatcher::~BackgroundFetchEventDispatcher() {
74 DCHECK_CURRENTLY_ON(BrowserThread::IO);
75 }
71 76
72 void BackgroundFetchEventDispatcher::DispatchBackgroundFetchAbortEvent( 77 void BackgroundFetchEventDispatcher::DispatchBackgroundFetchAbortEvent(
73 const BackgroundFetchRegistrationId& registration_id, 78 const BackgroundFetchRegistrationId& registration_id,
74 base::Closure finished_closure) { 79 base::Closure finished_closure) {
75 DCHECK_CURRENTLY_ON(BrowserThread::IO); 80 DCHECK_CURRENTLY_ON(BrowserThread::IO);
76 LoadServiceWorkerRegistrationForDispatch( 81 LoadServiceWorkerRegistrationForDispatch(
77 registration_id, ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_ABORT, 82 registration_id, ServiceWorkerMetrics::EventType::BACKGROUND_FETCH_ABORT,
78 std::move(finished_closure), 83 std::move(finished_closure),
79 base::Bind( 84 base::Bind(
80 &BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchAbortEvent, 85 &BackgroundFetchEventDispatcher::DoDispatchBackgroundFetchAbortEvent,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } else { 239 } else {
235 RecordDispatchResult(event, DISPATCH_RESULT_SUCCESS); 240 RecordDispatchResult(event, DISPATCH_RESULT_SUCCESS);
236 } 241 }
237 break; 242 break;
238 } 243 }
239 244
240 finished_closure.Run(); 245 finished_closure.Run();
241 } 246 }
242 247
243 } // namespace content 248 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698