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 3// found in the LICENSE file. 4 5#include "content/browser/service_worker/service_worker_registration.h" 6 7#include "content/public/browser/browser_thread.h" 8 9namespace content { 10 11ServiceWorkerRegistration::ServiceWorkerRegistration(const GURL& pattern, 12 const GURL& script_url, 13 int64 registration_id) 14 : pattern_(pattern), 15 script_url_(script_url), 16 registration_id_(registration_id), 17 is_shutdown_(false) { 18 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 19} 20 21ServiceWorkerRegistration::~ServiceWorkerRegistration() { 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 23 DCHECK(is_shutdown_); 24} 25 26void ServiceWorkerRegistration::Shutdown() { 27 DCHECK(!is_shutdown_); 28 if (active_version_) 29 active_version_->Shutdown(); 30 active_version_ = NULL; 31 if (pending_version_) 32 pending_version_->Shutdown(); 33 pending_version_ = NULL; 34 is_shutdown_ = true; 35} 36 37void ServiceWorkerRegistration::ActivatePendingVersion() { 38 active_version_->Shutdown(); 39 active_version_ = pending_version_; 40 pending_version_ = NULL; 41} 42 43} // namespace content 44