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

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

Issue 508433002: Remove implicit conversions from scoped_refptr to T* in content/browser/service_worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 <string> 5 #include <string>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); 100 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo);
101 info->request_time = base::Time::Now(); 101 info->request_time = base::Time::Now();
102 info->response_time = base::Time::Now(); 102 info->response_time = base::Time::Now();
103 info->was_cached = false; 103 info->was_cached = false;
104 info->headers = new net::HttpResponseHeaders(headers); 104 info->headers = new net::HttpResponseHeaders(headers);
105 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer = 105 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer =
106 new HttpResponseInfoIOBuffer(info.release()); 106 new HttpResponseInfoIOBuffer(info.release());
107 107
108 int rv = -1234; 108 int rv = -1234;
109 writer->WriteInfo(info_buffer, base::Bind(&OnIOComplete, &rv)); 109 writer->WriteInfo(info_buffer.get(), base::Bind(&OnIOComplete, &rv));
110 base::RunLoop().RunUntilIdle(); 110 base::RunLoop().RunUntilIdle();
111 EXPECT_LT(0, rv); 111 EXPECT_LT(0, rv);
112 112
113 rv = -1234; 113 rv = -1234;
114 writer->WriteData(body, length, base::Bind(&OnIOComplete, &rv)); 114 writer->WriteData(body, length, base::Bind(&OnIOComplete, &rv));
115 base::RunLoop().RunUntilIdle(); 115 base::RunLoop().RunUntilIdle();
116 EXPECT_EQ(length, rv); 116 EXPECT_EQ(length, rv);
117 } 117 }
118 118
119 void WriteStringResponse( 119 void WriteStringResponse(
120 ServiceWorkerStorage* storage, int64 id, 120 ServiceWorkerStorage* storage, int64 id,
121 const std::string& headers, 121 const std::string& headers,
122 const std::string& body) { 122 const std::string& body) {
123 scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(body.data())); 123 scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(body.data()));
124 WriteResponse(storage, id, headers, body_buffer, body.length()); 124 WriteResponse(storage, id, headers, body_buffer.get(), body.length());
125 } 125 }
126 126
127 void WriteBasicResponse(ServiceWorkerStorage* storage, int64 id) { 127 void WriteBasicResponse(ServiceWorkerStorage* storage, int64 id) {
128 scoped_ptr<ServiceWorkerResponseWriter> writer = 128 scoped_ptr<ServiceWorkerResponseWriter> writer =
129 storage->CreateResponseWriter(id); 129 storage->CreateResponseWriter(id);
130 130
131 const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0Content-Length: 5\0\0"; 131 const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0Content-Length: 5\0\0";
132 const char kHttpBody[] = "Hello"; 132 const char kHttpBody[] = "Hello";
133 std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); 133 std::string headers(kHttpHeaders, arraysize(kHttpHeaders));
134 WriteStringResponse(storage, id, headers, std::string(kHttpBody)); 134 WriteStringResponse(storage, id, headers, std::string(kHttpBody));
135 } 135 }
136 136
137 bool VerifyBasicResponse(ServiceWorkerStorage* storage, int64 id, 137 bool VerifyBasicResponse(ServiceWorkerStorage* storage, int64 id,
138 bool expected_positive_result) { 138 bool expected_positive_result) {
139 const std::string kExpectedHttpBody("Hello"); 139 const std::string kExpectedHttpBody("Hello");
140 scoped_ptr<ServiceWorkerResponseReader> reader = 140 scoped_ptr<ServiceWorkerResponseReader> reader =
141 storage->CreateResponseReader(id); 141 storage->CreateResponseReader(id);
142 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer = 142 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer =
143 new HttpResponseInfoIOBuffer(); 143 new HttpResponseInfoIOBuffer();
144 { 144 {
145 TestCompletionCallback cb; 145 TestCompletionCallback cb;
146 reader->ReadInfo(info_buffer, cb.callback()); 146 reader->ReadInfo(info_buffer.get(), cb.callback());
147 int rv = cb.WaitForResult(); 147 int rv = cb.WaitForResult();
148 if (expected_positive_result) 148 if (expected_positive_result)
149 EXPECT_LT(0, rv); 149 EXPECT_LT(0, rv);
150 if (rv <= 0) 150 if (rv <= 0)
151 return false; 151 return false;
152 } 152 }
153 153
154 std::string received_body; 154 std::string received_body;
155 { 155 {
156 const int kBigEnough = 512; 156 const int kBigEnough = 512;
157 scoped_refptr<net::IOBuffer> buffer = new IOBuffer(kBigEnough); 157 scoped_refptr<net::IOBuffer> buffer = new IOBuffer(kBigEnough);
158 TestCompletionCallback cb; 158 TestCompletionCallback cb;
159 reader->ReadData(buffer, kBigEnough, cb.callback()); 159 reader->ReadData(buffer.get(), kBigEnough, cb.callback());
160 int rv = cb.WaitForResult(); 160 int rv = cb.WaitForResult();
161 EXPECT_EQ(static_cast<int>(kExpectedHttpBody.size()), rv); 161 EXPECT_EQ(static_cast<int>(kExpectedHttpBody.size()), rv);
162 if (rv <= 0) 162 if (rv <= 0)
163 return false; 163 return false;
164 received_body.assign(buffer->data(), rv); 164 received_body.assign(buffer->data(), rv);
165 } 165 }
166 166
167 bool status_match = 167 bool status_match =
168 std::string("HONKYDORY") == 168 std::string("HONKYDORY") ==
169 info_buffer->http_info->headers->GetStatusText(); 169 info_buffer->http_info->headers->GetStatusText();
170 bool data_match = kExpectedHttpBody == received_body; 170 bool data_match = kExpectedHttpBody == received_body;
171 171
172 EXPECT_TRUE(status_match); 172 EXPECT_TRUE(status_match);
173 EXPECT_TRUE(data_match); 173 EXPECT_TRUE(data_match);
174 return status_match && data_match; 174 return status_match && data_match;
175 } 175 }
176 176
177 void WriteResponseOfSize(ServiceWorkerStorage* storage, int64 id, 177 void WriteResponseOfSize(ServiceWorkerStorage* storage, int64 id,
178 char val, int size) { 178 char val, int size) {
179 const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\00"; 179 const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\00";
180 std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); 180 std::string headers(kHttpHeaders, arraysize(kHttpHeaders));
181 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(size); 181 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(size);
182 memset(buffer->data(), val, size); 182 memset(buffer->data(), val, size);
183 WriteResponse(storage, id, headers, buffer, size); 183 WriteResponse(storage, id, headers, buffer.get(), size);
184 } 184 }
185 185
186 } // namespace 186 } // namespace
187 187
188 class ServiceWorkerStorageTest : public testing::Test { 188 class ServiceWorkerStorageTest : public testing::Test {
189 public: 189 public:
190 ServiceWorkerStorageTest() 190 ServiceWorkerStorageTest()
191 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { 191 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {
192 } 192 }
193 193
(...skipping 29 matching lines...) Expand all
223 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, 223 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
224 database->GetPurgeableResourceIds(purgeable_ids)); 224 database->GetPurgeableResourceIds(purgeable_ids));
225 } 225 }
226 226
227 protected: 227 protected:
228 ServiceWorkerStatusCode StoreRegistration( 228 ServiceWorkerStatusCode StoreRegistration(
229 scoped_refptr<ServiceWorkerRegistration> registration, 229 scoped_refptr<ServiceWorkerRegistration> registration,
230 scoped_refptr<ServiceWorkerVersion> version) { 230 scoped_refptr<ServiceWorkerVersion> version) {
231 bool was_called = false; 231 bool was_called = false;
232 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 232 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
233 storage()->StoreRegistration( 233 storage()->StoreRegistration(registration.get(),
234 registration, version, MakeStatusCallback(&was_called, &result)); 234 version.get(),
235 MakeStatusCallback(&was_called, &result));
235 EXPECT_FALSE(was_called); // always async 236 EXPECT_FALSE(was_called); // always async
236 base::RunLoop().RunUntilIdle(); 237 base::RunLoop().RunUntilIdle();
237 EXPECT_TRUE(was_called); 238 EXPECT_TRUE(was_called);
238 return result; 239 return result;
239 } 240 }
240 241
241 ServiceWorkerStatusCode DeleteRegistration( 242 ServiceWorkerStatusCode DeleteRegistration(
242 int64 registration_id, 243 int64 registration_id,
243 const GURL& origin) { 244 const GURL& origin) {
244 bool was_called = false; 245 bool was_called = false;
(...skipping 13 matching lines...) Expand all
258 MakeGetAllCallback(&was_called, registrations)); 259 MakeGetAllCallback(&was_called, registrations));
259 EXPECT_FALSE(was_called); // always async 260 EXPECT_FALSE(was_called); // always async
260 base::RunLoop().RunUntilIdle(); 261 base::RunLoop().RunUntilIdle();
261 EXPECT_TRUE(was_called); 262 EXPECT_TRUE(was_called);
262 } 263 }
263 264
264 ServiceWorkerStatusCode UpdateToActiveState( 265 ServiceWorkerStatusCode UpdateToActiveState(
265 scoped_refptr<ServiceWorkerRegistration> registration) { 266 scoped_refptr<ServiceWorkerRegistration> registration) {
266 bool was_called = false; 267 bool was_called = false;
267 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 268 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
268 storage()->UpdateToActiveState( 269 storage()->UpdateToActiveState(registration.get(),
269 registration, MakeStatusCallback(&was_called, &result)); 270 MakeStatusCallback(&was_called, &result));
270 EXPECT_FALSE(was_called); // always async 271 EXPECT_FALSE(was_called); // always async
271 base::RunLoop().RunUntilIdle(); 272 base::RunLoop().RunUntilIdle();
272 EXPECT_TRUE(was_called); 273 EXPECT_TRUE(was_called);
273 return result; 274 return result;
274 } 275 }
275 276
276 void UpdateLastUpdateCheckTime(ServiceWorkerRegistration* registration) { 277 void UpdateLastUpdateCheckTime(ServiceWorkerRegistration* registration) {
277 storage()->UpdateLastUpdateCheckTime(registration); 278 storage()->UpdateLastUpdateCheckTime(registration);
278 base::RunLoop().RunUntilIdle(); 279 base::RunLoop().RunUntilIdle();
279 } 280 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 const int64 kRegistrationId = 0; 330 const int64 kRegistrationId = 0;
330 const int64 kVersionId = 0; 331 const int64 kVersionId = 0;
331 const base::Time kToday = base::Time::Now(); 332 const base::Time kToday = base::Time::Now();
332 const base::Time kYesterday = kToday - base::TimeDelta::FromDays(1); 333 const base::Time kYesterday = kToday - base::TimeDelta::FromDays(1);
333 334
334 scoped_refptr<ServiceWorkerRegistration> found_registration; 335 scoped_refptr<ServiceWorkerRegistration> found_registration;
335 336
336 // We shouldn't find anything without having stored anything. 337 // We shouldn't find anything without having stored anything.
337 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 338 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
338 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 339 FindRegistrationForDocument(kDocumentUrl, &found_registration));
339 EXPECT_FALSE(found_registration); 340 EXPECT_FALSE(found_registration.get());
340 341
341 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 342 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
342 FindRegistrationForPattern(kScope, &found_registration)); 343 FindRegistrationForPattern(kScope, &found_registration));
343 EXPECT_FALSE(found_registration); 344 EXPECT_FALSE(found_registration.get());
344 345
345 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 346 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
346 FindRegistrationForId( 347 FindRegistrationForId(
347 kRegistrationId, kScope.GetOrigin(), &found_registration)); 348 kRegistrationId, kScope.GetOrigin(), &found_registration));
348 EXPECT_FALSE(found_registration); 349 EXPECT_FALSE(found_registration.get());
349 350
350 // Store something. 351 // Store something.
351 scoped_refptr<ServiceWorkerRegistration> live_registration = 352 scoped_refptr<ServiceWorkerRegistration> live_registration =
352 new ServiceWorkerRegistration( 353 new ServiceWorkerRegistration(
353 kScope, kScript, kRegistrationId, context_ptr_); 354 kScope, kScript, kRegistrationId, context_ptr_);
354 scoped_refptr<ServiceWorkerVersion> live_version = 355 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion(
355 new ServiceWorkerVersion( 356 live_registration.get(), kVersionId, context_ptr_);
356 live_registration, kVersionId, context_ptr_);
357 live_version->SetStatus(ServiceWorkerVersion::INSTALLED); 357 live_version->SetStatus(ServiceWorkerVersion::INSTALLED);
358 live_registration->SetWaitingVersion(live_version); 358 live_registration->SetWaitingVersion(live_version.get());
359 live_registration->set_last_update_check(kYesterday); 359 live_registration->set_last_update_check(kYesterday);
360 EXPECT_EQ(SERVICE_WORKER_OK, 360 EXPECT_EQ(SERVICE_WORKER_OK,
361 StoreRegistration(live_registration, live_version)); 361 StoreRegistration(live_registration, live_version));
362 362
363 // Now we should find it and get the live ptr back immediately. 363 // Now we should find it and get the live ptr back immediately.
364 EXPECT_EQ(SERVICE_WORKER_OK, 364 EXPECT_EQ(SERVICE_WORKER_OK,
365 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 365 FindRegistrationForDocument(kDocumentUrl, &found_registration));
366 EXPECT_EQ(live_registration, found_registration); 366 EXPECT_EQ(live_registration, found_registration);
367 found_registration = NULL; 367 found_registration = NULL;
368 368
369 // But FindRegistrationForPattern is always async. 369 // But FindRegistrationForPattern is always async.
370 EXPECT_EQ(SERVICE_WORKER_OK, 370 EXPECT_EQ(SERVICE_WORKER_OK,
371 FindRegistrationForPattern(kScope, &found_registration)); 371 FindRegistrationForPattern(kScope, &found_registration));
372 EXPECT_EQ(live_registration, found_registration); 372 EXPECT_EQ(live_registration, found_registration);
373 found_registration = NULL; 373 found_registration = NULL;
374 374
375 // Can be found by id too. 375 // Can be found by id too.
376 EXPECT_EQ(SERVICE_WORKER_OK, 376 EXPECT_EQ(SERVICE_WORKER_OK,
377 FindRegistrationForId( 377 FindRegistrationForId(
378 kRegistrationId, kScope.GetOrigin(), &found_registration)); 378 kRegistrationId, kScope.GetOrigin(), &found_registration));
379 ASSERT_TRUE(found_registration); 379 ASSERT_TRUE(found_registration.get());
380 EXPECT_EQ(kRegistrationId, found_registration->id()); 380 EXPECT_EQ(kRegistrationId, found_registration->id());
381 EXPECT_EQ(live_registration, found_registration); 381 EXPECT_EQ(live_registration, found_registration);
382 found_registration = NULL; 382 found_registration = NULL;
383 383
384 // Drop the live registration, but keep the version live. 384 // Drop the live registration, but keep the version live.
385 live_registration = NULL; 385 live_registration = NULL;
386 386
387 // Now FindRegistrationForDocument should be async. 387 // Now FindRegistrationForDocument should be async.
388 EXPECT_EQ(SERVICE_WORKER_OK, 388 EXPECT_EQ(SERVICE_WORKER_OK,
389 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 389 FindRegistrationForDocument(kDocumentUrl, &found_registration));
390 ASSERT_TRUE(found_registration); 390 ASSERT_TRUE(found_registration.get());
391 EXPECT_EQ(kRegistrationId, found_registration->id()); 391 EXPECT_EQ(kRegistrationId, found_registration->id());
392 EXPECT_TRUE(found_registration->HasOneRef()); 392 EXPECT_TRUE(found_registration->HasOneRef());
393 EXPECT_EQ(live_version, found_registration->waiting_version()); 393 EXPECT_EQ(live_version.get(), found_registration->waiting_version());
394 found_registration = NULL; 394 found_registration = NULL;
395 395
396 // Drop the live version too. 396 // Drop the live version too.
397 live_version = NULL; 397 live_version = NULL;
398 398
399 // And FindRegistrationForPattern is always async. 399 // And FindRegistrationForPattern is always async.
400 EXPECT_EQ(SERVICE_WORKER_OK, 400 EXPECT_EQ(SERVICE_WORKER_OK,
401 FindRegistrationForPattern(kScope, &found_registration)); 401 FindRegistrationForPattern(kScope, &found_registration));
402 ASSERT_TRUE(found_registration); 402 ASSERT_TRUE(found_registration.get());
403 EXPECT_EQ(kRegistrationId, found_registration->id()); 403 EXPECT_EQ(kRegistrationId, found_registration->id());
404 EXPECT_TRUE(found_registration->HasOneRef()); 404 EXPECT_TRUE(found_registration->HasOneRef());
405 EXPECT_FALSE(found_registration->active_version()); 405 EXPECT_FALSE(found_registration->active_version());
406 ASSERT_TRUE(found_registration->waiting_version()); 406 ASSERT_TRUE(found_registration->waiting_version());
407 EXPECT_EQ(kYesterday, found_registration->last_update_check()); 407 EXPECT_EQ(kYesterday, found_registration->last_update_check());
408 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, 408 EXPECT_EQ(ServiceWorkerVersion::INSTALLED,
409 found_registration->waiting_version()->status()); 409 found_registration->waiting_version()->status());
410 410
411 // Update to active and update the last check time. 411 // Update to active and update the last check time.
412 scoped_refptr<ServiceWorkerVersion> temp_version = 412 scoped_refptr<ServiceWorkerVersion> temp_version =
413 found_registration->waiting_version(); 413 found_registration->waiting_version();
414 temp_version->SetStatus(ServiceWorkerVersion::ACTIVATED); 414 temp_version->SetStatus(ServiceWorkerVersion::ACTIVATED);
415 found_registration->SetActiveVersion(temp_version); 415 found_registration->SetActiveVersion(temp_version.get());
416 temp_version = NULL; 416 temp_version = NULL;
417 EXPECT_EQ(SERVICE_WORKER_OK, UpdateToActiveState(found_registration)); 417 EXPECT_EQ(SERVICE_WORKER_OK, UpdateToActiveState(found_registration));
418 found_registration->set_last_update_check(kToday); 418 found_registration->set_last_update_check(kToday);
419 UpdateLastUpdateCheckTime(found_registration); 419 UpdateLastUpdateCheckTime(found_registration.get());
420 420
421 found_registration = NULL; 421 found_registration = NULL;
422 422
423 // Trying to update a unstored registration to active should fail. 423 // Trying to update a unstored registration to active should fail.
424 scoped_refptr<ServiceWorkerRegistration> unstored_registration = 424 scoped_refptr<ServiceWorkerRegistration> unstored_registration =
425 new ServiceWorkerRegistration( 425 new ServiceWorkerRegistration(
426 kScope, kScript, kRegistrationId + 1, context_ptr_); 426 kScope, kScript, kRegistrationId + 1, context_ptr_);
427 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 427 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
428 UpdateToActiveState(unstored_registration)); 428 UpdateToActiveState(unstored_registration));
429 unstored_registration = NULL; 429 unstored_registration = NULL;
430 430
431 // The Find methods should return a registration with an active version 431 // The Find methods should return a registration with an active version
432 // and the expected update time. 432 // and the expected update time.
433 EXPECT_EQ(SERVICE_WORKER_OK, 433 EXPECT_EQ(SERVICE_WORKER_OK,
434 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 434 FindRegistrationForDocument(kDocumentUrl, &found_registration));
435 ASSERT_TRUE(found_registration); 435 ASSERT_TRUE(found_registration.get());
436 EXPECT_EQ(kRegistrationId, found_registration->id()); 436 EXPECT_EQ(kRegistrationId, found_registration->id());
437 EXPECT_TRUE(found_registration->HasOneRef()); 437 EXPECT_TRUE(found_registration->HasOneRef());
438 EXPECT_FALSE(found_registration->waiting_version()); 438 EXPECT_FALSE(found_registration->waiting_version());
439 ASSERT_TRUE(found_registration->active_version()); 439 ASSERT_TRUE(found_registration->active_version());
440 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED, 440 EXPECT_EQ(ServiceWorkerVersion::ACTIVATED,
441 found_registration->active_version()->status()); 441 found_registration->active_version()->status());
442 EXPECT_EQ(kToday, found_registration->last_update_check()); 442 EXPECT_EQ(kToday, found_registration->last_update_check());
443 443
444 // Delete from storage but with a instance still live. 444 // Delete from storage but with a instance still live.
445 EXPECT_TRUE(context_->GetLiveVersion(kRegistrationId)); 445 EXPECT_TRUE(context_->GetLiveVersion(kRegistrationId));
446 EXPECT_EQ(SERVICE_WORKER_OK, 446 EXPECT_EQ(SERVICE_WORKER_OK,
447 DeleteRegistration(kRegistrationId, kScope.GetOrigin())); 447 DeleteRegistration(kRegistrationId, kScope.GetOrigin()));
448 EXPECT_TRUE(context_->GetLiveVersion(kRegistrationId)); 448 EXPECT_TRUE(context_->GetLiveVersion(kRegistrationId));
449 449
450 // Should no longer be found. 450 // Should no longer be found.
451 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 451 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
452 FindRegistrationForId( 452 FindRegistrationForId(
453 kRegistrationId, kScope.GetOrigin(), &found_registration)); 453 kRegistrationId, kScope.GetOrigin(), &found_registration));
454 EXPECT_FALSE(found_registration); 454 EXPECT_FALSE(found_registration.get());
455 455
456 // Deleting an unstored registration should succeed. 456 // Deleting an unstored registration should succeed.
457 EXPECT_EQ(SERVICE_WORKER_OK, 457 EXPECT_EQ(SERVICE_WORKER_OK,
458 DeleteRegistration(kRegistrationId + 1, kScope.GetOrigin())); 458 DeleteRegistration(kRegistrationId + 1, kScope.GetOrigin()));
459 } 459 }
460 460
461 TEST_F(ServiceWorkerStorageTest, InstallingRegistrationsAreFindable) { 461 TEST_F(ServiceWorkerStorageTest, InstallingRegistrationsAreFindable) {
462 const GURL kScope("http://www.test.not/scope/"); 462 const GURL kScope("http://www.test.not/scope/");
463 const GURL kScript("http://www.test.not/script.js"); 463 const GURL kScript("http://www.test.not/script.js");
464 const GURL kDocumentUrl("http://www.test.not/scope/document.html"); 464 const GURL kDocumentUrl("http://www.test.not/scope/document.html");
465 const int64 kRegistrationId = 0; 465 const int64 kRegistrationId = 0;
466 const int64 kVersionId = 0; 466 const int64 kVersionId = 0;
467 467
468 scoped_refptr<ServiceWorkerRegistration> found_registration; 468 scoped_refptr<ServiceWorkerRegistration> found_registration;
469 469
470 // Create an unstored registration. 470 // Create an unstored registration.
471 scoped_refptr<ServiceWorkerRegistration> live_registration = 471 scoped_refptr<ServiceWorkerRegistration> live_registration =
472 new ServiceWorkerRegistration( 472 new ServiceWorkerRegistration(
473 kScope, kScript, kRegistrationId, context_ptr_); 473 kScope, kScript, kRegistrationId, context_ptr_);
474 scoped_refptr<ServiceWorkerVersion> live_version = 474 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion(
475 new ServiceWorkerVersion( 475 live_registration.get(), kVersionId, context_ptr_);
476 live_registration, kVersionId, context_ptr_);
477 live_version->SetStatus(ServiceWorkerVersion::INSTALLING); 476 live_version->SetStatus(ServiceWorkerVersion::INSTALLING);
478 live_registration->SetWaitingVersion(live_version); 477 live_registration->SetWaitingVersion(live_version.get());
479 478
480 // Should not be findable, including by GetAllRegistrations. 479 // Should not be findable, including by GetAllRegistrations.
481 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 480 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
482 FindRegistrationForId( 481 FindRegistrationForId(
483 kRegistrationId, kScope.GetOrigin(), &found_registration)); 482 kRegistrationId, kScope.GetOrigin(), &found_registration));
484 EXPECT_FALSE(found_registration); 483 EXPECT_FALSE(found_registration.get());
485 484
486 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 485 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
487 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 486 FindRegistrationForDocument(kDocumentUrl, &found_registration));
488 EXPECT_FALSE(found_registration); 487 EXPECT_FALSE(found_registration.get());
489 488
490 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 489 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
491 FindRegistrationForPattern(kScope, &found_registration)); 490 FindRegistrationForPattern(kScope, &found_registration));
492 EXPECT_FALSE(found_registration); 491 EXPECT_FALSE(found_registration.get());
493 492
494 std::vector<ServiceWorkerRegistrationInfo> all_registrations; 493 std::vector<ServiceWorkerRegistrationInfo> all_registrations;
495 GetAllRegistrations(&all_registrations); 494 GetAllRegistrations(&all_registrations);
496 EXPECT_TRUE(all_registrations.empty()); 495 EXPECT_TRUE(all_registrations.empty());
497 496
498 // Notify storage of it being installed. 497 // Notify storage of it being installed.
499 storage()->NotifyInstallingRegistration(live_registration); 498 storage()->NotifyInstallingRegistration(live_registration.get());
500 499
501 // Now should be findable. 500 // Now should be findable.
502 EXPECT_EQ(SERVICE_WORKER_OK, 501 EXPECT_EQ(SERVICE_WORKER_OK,
503 FindRegistrationForId( 502 FindRegistrationForId(
504 kRegistrationId, kScope.GetOrigin(), &found_registration)); 503 kRegistrationId, kScope.GetOrigin(), &found_registration));
505 EXPECT_EQ(live_registration, found_registration); 504 EXPECT_EQ(live_registration, found_registration);
506 found_registration = NULL; 505 found_registration = NULL;
507 506
508 EXPECT_EQ(SERVICE_WORKER_OK, 507 EXPECT_EQ(SERVICE_WORKER_OK,
509 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 508 FindRegistrationForDocument(kDocumentUrl, &found_registration));
510 EXPECT_EQ(live_registration, found_registration); 509 EXPECT_EQ(live_registration, found_registration);
511 found_registration = NULL; 510 found_registration = NULL;
512 511
513 EXPECT_EQ(SERVICE_WORKER_OK, 512 EXPECT_EQ(SERVICE_WORKER_OK,
514 FindRegistrationForPattern(kScope, &found_registration)); 513 FindRegistrationForPattern(kScope, &found_registration));
515 EXPECT_EQ(live_registration, found_registration); 514 EXPECT_EQ(live_registration, found_registration);
516 found_registration = NULL; 515 found_registration = NULL;
517 516
518 GetAllRegistrations(&all_registrations); 517 GetAllRegistrations(&all_registrations);
519 EXPECT_EQ(1u, all_registrations.size()); 518 EXPECT_EQ(1u, all_registrations.size());
520 all_registrations.clear(); 519 all_registrations.clear();
521 520
522 // Notify storage of installation no longer happening. 521 // Notify storage of installation no longer happening.
523 storage()->NotifyDoneInstallingRegistration( 522 storage()->NotifyDoneInstallingRegistration(
524 live_registration, NULL, SERVICE_WORKER_OK); 523 live_registration.get(), NULL, SERVICE_WORKER_OK);
525 524
526 // Once again, should not be findable. 525 // Once again, should not be findable.
527 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 526 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
528 FindRegistrationForId( 527 FindRegistrationForId(
529 kRegistrationId, kScope.GetOrigin(), &found_registration)); 528 kRegistrationId, kScope.GetOrigin(), &found_registration));
530 EXPECT_FALSE(found_registration); 529 EXPECT_FALSE(found_registration.get());
531 530
532 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 531 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
533 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 532 FindRegistrationForDocument(kDocumentUrl, &found_registration));
534 EXPECT_FALSE(found_registration); 533 EXPECT_FALSE(found_registration.get());
535 534
536 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, 535 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND,
537 FindRegistrationForPattern(kScope, &found_registration)); 536 FindRegistrationForPattern(kScope, &found_registration));
538 EXPECT_FALSE(found_registration); 537 EXPECT_FALSE(found_registration.get());
539 538
540 GetAllRegistrations(&all_registrations); 539 GetAllRegistrations(&all_registrations);
541 EXPECT_TRUE(all_registrations.empty()); 540 EXPECT_TRUE(all_registrations.empty());
542 } 541 }
543 542
544 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { 543 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest {
545 public: 544 public:
546 virtual void SetUp() OVERRIDE { 545 virtual void SetUp() OVERRIDE {
547 ServiceWorkerStorageTest::SetUp(); 546 ServiceWorkerStorageTest::SetUp();
548 547
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 EXPECT_TRUE(verify_ids.empty()); 694 EXPECT_TRUE(verify_ids.empty());
696 695
697 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); 696 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
698 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); 697 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
699 } 698 }
700 699
701 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { 700 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
702 // Promote the worker to active and add a controllee. 701 // Promote the worker to active and add a controllee.
703 registration_->SetActiveVersion(registration_->waiting_version()); 702 registration_->SetActiveVersion(registration_->waiting_version());
704 storage()->UpdateToActiveState( 703 storage()->UpdateToActiveState(
705 registration_, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 704 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
706 scoped_ptr<ServiceWorkerProviderHost> host( 705 scoped_ptr<ServiceWorkerProviderHost> host(
707 new ServiceWorkerProviderHost(33 /* dummy render process id */, 706 new ServiceWorkerProviderHost(33 /* dummy render process id */,
708 1 /* dummy provider_id */, 707 1 /* dummy provider_id */,
709 context_->AsWeakPtr(), 708 context_->AsWeakPtr(),
710 NULL)); 709 NULL));
711 registration_->active_version()->AddControllee(host.get()); 710 registration_->active_version()->AddControllee(host.get());
712 711
713 bool was_called = false; 712 bool was_called = false;
714 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 713 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
715 std::set<int64> verify_ids; 714 std::set<int64> verify_ids;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 #if defined(OS_ANDROID) 752 #if defined(OS_ANDROID)
754 #define MAYBE_CleanupOnRestart DISABLED_CleanupOnRestart 753 #define MAYBE_CleanupOnRestart DISABLED_CleanupOnRestart
755 #else 754 #else
756 #define MAYBE_CleanupOnRestart CleanupOnRestart 755 #define MAYBE_CleanupOnRestart CleanupOnRestart
757 #endif 756 #endif
758 TEST_F(ServiceWorkerResourceStorageDiskTest, MAYBE_CleanupOnRestart) { 757 TEST_F(ServiceWorkerResourceStorageDiskTest, MAYBE_CleanupOnRestart) {
759 // Promote the worker to active and add a controllee. 758 // Promote the worker to active and add a controllee.
760 registration_->SetActiveVersion(registration_->waiting_version()); 759 registration_->SetActiveVersion(registration_->waiting_version());
761 registration_->SetWaitingVersion(NULL); 760 registration_->SetWaitingVersion(NULL);
762 storage()->UpdateToActiveState( 761 storage()->UpdateToActiveState(
763 registration_, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 762 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
764 scoped_ptr<ServiceWorkerProviderHost> host( 763 scoped_ptr<ServiceWorkerProviderHost> host(
765 new ServiceWorkerProviderHost(33 /* dummy render process id */, 764 new ServiceWorkerProviderHost(33 /* dummy render process id */,
766 1 /* dummy provider_id */, 765 1 /* dummy provider_id */,
767 context_->AsWeakPtr(), 766 context_->AsWeakPtr(),
768 NULL)); 767 NULL));
769 registration_->active_version()->AddControllee(host.get()); 768 registration_->active_version()->AddControllee(host.get());
770 769
771 bool was_called = false; 770 bool was_called = false;
772 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 771 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
773 std::set<int64> verify_ids; 772 std::set<int64> verify_ids;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); 840 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
842 EXPECT_FALSE( 841 EXPECT_FALSE(
843 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, false)); 842 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, false));
844 EXPECT_TRUE(VerifyBasicResponse(storage(), kNewResourceId, true)); 843 EXPECT_TRUE(VerifyBasicResponse(storage(), kNewResourceId, true));
845 } 844 }
846 845
847 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { 846 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
848 // Promote the worker to active worker and add a controllee. 847 // Promote the worker to active worker and add a controllee.
849 registration_->SetActiveVersion(registration_->waiting_version()); 848 registration_->SetActiveVersion(registration_->waiting_version());
850 storage()->UpdateToActiveState( 849 storage()->UpdateToActiveState(
851 registration_, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 850 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
852 scoped_ptr<ServiceWorkerProviderHost> host( 851 scoped_ptr<ServiceWorkerProviderHost> host(
853 new ServiceWorkerProviderHost(33 /* dummy render process id */, 852 new ServiceWorkerProviderHost(33 /* dummy render process id */,
854 1 /* dummy provider_id */, 853 1 /* dummy provider_id */,
855 context_->AsWeakPtr(), 854 context_->AsWeakPtr(),
856 NULL)); 855 NULL));
857 registration_->active_version()->AddControllee(host.get()); 856 registration_->active_version()->AddControllee(host.get());
858 857
859 bool was_called = false; 858 bool was_called = false;
860 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 859 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
861 std::set<int64> verify_ids; 860 std::set<int64> verify_ids;
862 861
863 // Make an updated registration. 862 // Make an updated registration.
864 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( 863 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion(
865 registration_, storage()->NewVersionId(), context_ptr_); 864 registration_.get(), storage()->NewVersionId(), context_ptr_);
866 live_version->SetStatus(ServiceWorkerVersion::NEW); 865 live_version->SetStatus(ServiceWorkerVersion::NEW);
867 registration_->SetWaitingVersion(live_version); 866 registration_->SetWaitingVersion(live_version.get());
868 867
869 // Writing the registration should move the old version's resources to the 868 // Writing the registration should move the old version's resources to the
870 // purgeable list but keep them available. 869 // purgeable list but keep them available.
871 storage()->StoreRegistration( 870 storage()->StoreRegistration(
872 registration_, 871 registration_.get(),
873 registration_->waiting_version(), 872 registration_->waiting_version(),
874 base::Bind(&VerifyPurgeableListStatusCallback, 873 base::Bind(&VerifyPurgeableListStatusCallback,
875 base::Unretained(storage()->database_.get()), 874 base::Unretained(storage()->database_.get()),
876 &verify_ids, 875 &verify_ids,
877 &was_called, 876 &was_called,
878 &result)); 877 &result));
879 registration_->active_version()->Doom(); 878 registration_->active_version()->Doom();
880 base::RunLoop().RunUntilIdle(); 879 base::RunLoop().RunUntilIdle();
881 ASSERT_TRUE(was_called); 880 ASSERT_TRUE(was_called);
882 EXPECT_EQ(SERVICE_WORKER_OK, result); 881 EXPECT_EQ(SERVICE_WORKER_OK, result);
(...skipping 24 matching lines...) Expand all
907 scoped_refptr<ServiceWorkerRegistration> found_registration; 906 scoped_refptr<ServiceWorkerRegistration> found_registration;
908 907
909 // Registration for "/scope/". 908 // Registration for "/scope/".
910 const GURL kScope1("http://www.example.com/scope/"); 909 const GURL kScope1("http://www.example.com/scope/");
911 const GURL kScript1("http://www.example.com/script1.js"); 910 const GURL kScript1("http://www.example.com/script1.js");
912 const int64 kRegistrationId1 = 1; 911 const int64 kRegistrationId1 = 1;
913 const int64 kVersionId1 = 1; 912 const int64 kVersionId1 = 1;
914 scoped_refptr<ServiceWorkerRegistration> live_registration1 = 913 scoped_refptr<ServiceWorkerRegistration> live_registration1 =
915 new ServiceWorkerRegistration( 914 new ServiceWorkerRegistration(
916 kScope1, kScript1, kRegistrationId1, context_ptr_); 915 kScope1, kScript1, kRegistrationId1, context_ptr_);
917 scoped_refptr<ServiceWorkerVersion> live_version1 = 916 scoped_refptr<ServiceWorkerVersion> live_version1 = new ServiceWorkerVersion(
918 new ServiceWorkerVersion( 917 live_registration1.get(), kVersionId1, context_ptr_);
919 live_registration1, kVersionId1, context_ptr_);
920 live_version1->SetStatus(ServiceWorkerVersion::INSTALLED); 918 live_version1->SetStatus(ServiceWorkerVersion::INSTALLED);
921 live_registration1->SetWaitingVersion(live_version1); 919 live_registration1->SetWaitingVersion(live_version1.get());
922 920
923 // Registration for "/scope/foo". 921 // Registration for "/scope/foo".
924 const GURL kScope2("http://www.example.com/scope/foo"); 922 const GURL kScope2("http://www.example.com/scope/foo");
925 const GURL kScript2("http://www.example.com/script2.js"); 923 const GURL kScript2("http://www.example.com/script2.js");
926 const int64 kRegistrationId2 = 2; 924 const int64 kRegistrationId2 = 2;
927 const int64 kVersionId2 = 2; 925 const int64 kVersionId2 = 2;
928 scoped_refptr<ServiceWorkerRegistration> live_registration2 = 926 scoped_refptr<ServiceWorkerRegistration> live_registration2 =
929 new ServiceWorkerRegistration( 927 new ServiceWorkerRegistration(
930 kScope2, kScript2, kRegistrationId2, context_ptr_); 928 kScope2, kScript2, kRegistrationId2, context_ptr_);
931 scoped_refptr<ServiceWorkerVersion> live_version2 = 929 scoped_refptr<ServiceWorkerVersion> live_version2 = new ServiceWorkerVersion(
932 new ServiceWorkerVersion( 930 live_registration2.get(), kVersionId2, context_ptr_);
933 live_registration2, kVersionId2, context_ptr_);
934 live_version2->SetStatus(ServiceWorkerVersion::INSTALLED); 931 live_version2->SetStatus(ServiceWorkerVersion::INSTALLED);
935 live_registration2->SetWaitingVersion(live_version2); 932 live_registration2->SetWaitingVersion(live_version2.get());
936 933
937 // Registration for "/scope/foobar". 934 // Registration for "/scope/foobar".
938 const GURL kScope3("http://www.example.com/scope/foobar"); 935 const GURL kScope3("http://www.example.com/scope/foobar");
939 const GURL kScript3("http://www.example.com/script3.js"); 936 const GURL kScript3("http://www.example.com/script3.js");
940 const int64 kRegistrationId3 = 3; 937 const int64 kRegistrationId3 = 3;
941 const int64 kVersionId3 = 3; 938 const int64 kVersionId3 = 3;
942 scoped_refptr<ServiceWorkerRegistration> live_registration3 = 939 scoped_refptr<ServiceWorkerRegistration> live_registration3 =
943 new ServiceWorkerRegistration( 940 new ServiceWorkerRegistration(
944 kScope3, kScript3, kRegistrationId3, context_ptr_); 941 kScope3, kScript3, kRegistrationId3, context_ptr_);
945 scoped_refptr<ServiceWorkerVersion> live_version3 = 942 scoped_refptr<ServiceWorkerVersion> live_version3 = new ServiceWorkerVersion(
946 new ServiceWorkerVersion( 943 live_registration3.get(), kVersionId3, context_ptr_);
947 live_registration3, kVersionId3, context_ptr_);
948 live_version3->SetStatus(ServiceWorkerVersion::INSTALLED); 944 live_version3->SetStatus(ServiceWorkerVersion::INSTALLED);
949 live_registration3->SetWaitingVersion(live_version3); 945 live_registration3->SetWaitingVersion(live_version3.get());
950 946
951 // Notify storage of they being installed. 947 // Notify storage of they being installed.
952 storage()->NotifyInstallingRegistration(live_registration1); 948 storage()->NotifyInstallingRegistration(live_registration1.get());
953 storage()->NotifyInstallingRegistration(live_registration2); 949 storage()->NotifyInstallingRegistration(live_registration2.get());
954 storage()->NotifyInstallingRegistration(live_registration3); 950 storage()->NotifyInstallingRegistration(live_registration3.get());
955 951
956 // Find a registration among installing ones. 952 // Find a registration among installing ones.
957 EXPECT_EQ(SERVICE_WORKER_OK, 953 EXPECT_EQ(SERVICE_WORKER_OK,
958 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 954 FindRegistrationForDocument(kDocumentUrl, &found_registration));
959 EXPECT_EQ(live_registration2, found_registration); 955 EXPECT_EQ(live_registration2, found_registration);
960 found_registration = NULL; 956 found_registration = NULL;
961 957
962 // Store registrations. 958 // Store registrations.
963 EXPECT_EQ(SERVICE_WORKER_OK, 959 EXPECT_EQ(SERVICE_WORKER_OK,
964 StoreRegistration(live_registration1, live_version1)); 960 StoreRegistration(live_registration1, live_version1));
965 EXPECT_EQ(SERVICE_WORKER_OK, 961 EXPECT_EQ(SERVICE_WORKER_OK,
966 StoreRegistration(live_registration2, live_version2)); 962 StoreRegistration(live_registration2, live_version2));
967 EXPECT_EQ(SERVICE_WORKER_OK, 963 EXPECT_EQ(SERVICE_WORKER_OK,
968 StoreRegistration(live_registration3, live_version3)); 964 StoreRegistration(live_registration3, live_version3));
969 965
970 // Notify storage of installations no longer happening. 966 // Notify storage of installations no longer happening.
971 storage()->NotifyDoneInstallingRegistration( 967 storage()->NotifyDoneInstallingRegistration(
972 live_registration1, NULL, SERVICE_WORKER_OK); 968 live_registration1.get(), NULL, SERVICE_WORKER_OK);
973 storage()->NotifyDoneInstallingRegistration( 969 storage()->NotifyDoneInstallingRegistration(
974 live_registration2, NULL, SERVICE_WORKER_OK); 970 live_registration2.get(), NULL, SERVICE_WORKER_OK);
975 storage()->NotifyDoneInstallingRegistration( 971 storage()->NotifyDoneInstallingRegistration(
976 live_registration3, NULL, SERVICE_WORKER_OK); 972 live_registration3.get(), NULL, SERVICE_WORKER_OK);
977 973
978 // Find a registration among installed ones. 974 // Find a registration among installed ones.
979 EXPECT_EQ(SERVICE_WORKER_OK, 975 EXPECT_EQ(SERVICE_WORKER_OK,
980 FindRegistrationForDocument(kDocumentUrl, &found_registration)); 976 FindRegistrationForDocument(kDocumentUrl, &found_registration));
981 EXPECT_EQ(live_registration2, found_registration); 977 EXPECT_EQ(live_registration2, found_registration);
982 } 978 }
983 979
984 TEST_F(ServiceWorkerStorageTest, CompareResources) { 980 TEST_F(ServiceWorkerStorageTest, CompareResources) {
985 // Compare two small responses containing the same data. 981 // Compare two small responses containing the same data.
986 WriteBasicResponse(storage(), 1); 982 WriteBasicResponse(storage(), 1);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 are_equal = true; 1033 are_equal = true;
1038 storage()->CompareScriptResources( 1034 storage()->CompareScriptResources(
1039 5, 6, 1035 5, 6,
1040 base::Bind(&OnCompareComplete, &status, &are_equal)); 1036 base::Bind(&OnCompareComplete, &status, &are_equal));
1041 base::RunLoop().RunUntilIdle(); 1037 base::RunLoop().RunUntilIdle();
1042 EXPECT_EQ(SERVICE_WORKER_OK, status); 1038 EXPECT_EQ(SERVICE_WORKER_OK, status);
1043 EXPECT_FALSE(are_equal); 1039 EXPECT_FALSE(are_equal);
1044 } 1040 }
1045 1041
1046 } // namespace content 1042 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698