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

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

Issue 360123002: ServiceWorker: some more groundwork in support of the update process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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_registration.h" 5 #include "content/browser/service_worker/service_worker_registration.h"
6 6
7 7
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 26 matching lines...) Expand all
37 base::RunLoop().RunUntilIdle(); 37 base::RunLoop().RunUntilIdle();
38 } 38 }
39 39
40 protected: 40 protected:
41 scoped_ptr<ServiceWorkerContextCore> context_; 41 scoped_ptr<ServiceWorkerContextCore> context_;
42 base::WeakPtr<ServiceWorkerContextCore> context_ptr_; 42 base::WeakPtr<ServiceWorkerContextCore> context_ptr_;
43 base::MessageLoopForIO message_loop_; 43 base::MessageLoopForIO message_loop_;
44 BrowserThreadImpl io_thread_; 44 BrowserThreadImpl io_thread_;
45 }; 45 };
46 46
47 // Make sure that activation does not leak
48 TEST_F(ServiceWorkerRegistrationTest, ActivatePending) {
49 int64 registration_id = -1L;
50 scoped_refptr<ServiceWorkerRegistration> registration =
51 new ServiceWorkerRegistration(
52 GURL("http://www.example.com/*"),
53 GURL("http://www.example.com/service_worker.js"),
54 registration_id,
55 context_ptr_);
56
57 const int64 version_1_id = 1L;
58 const int64 version_2_id = 2L;
59 scoped_refptr<ServiceWorkerVersion> version_1 =
60 new ServiceWorkerVersion(registration, version_1_id, context_ptr_);
61 version_1->SetStatus(ServiceWorkerVersion::ACTIVE);
62 registration->set_active_version(version_1);
63
64 scoped_refptr<ServiceWorkerVersion> version_2 =
65 new ServiceWorkerVersion(registration, version_2_id, context_ptr_);
66 registration->set_waiting_version(version_2);
67
68 registration->ActivateWaitingVersion();
69 DCHECK_EQ(version_2, registration->active_version());
70 DCHECK(version_1->HasOneRef());
71 version_1 = NULL;
72
73 DCHECK(!version_2->HasOneRef());
74 }
75
76 } // namespace content 47 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698