OLD | NEW |
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_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 *was_called = true; | 55 *was_called = true; |
56 *result = status; | 56 *result = status; |
57 } | 57 } |
58 | 58 |
59 ServiceWorkerStorage::StatusCallback MakeStatusCallback( | 59 ServiceWorkerStorage::StatusCallback MakeStatusCallback( |
60 bool* was_called, | 60 bool* was_called, |
61 ServiceWorkerStatusCode* result) { | 61 ServiceWorkerStatusCode* result) { |
62 return base::Bind(&StatusCallback, was_called, result); | 62 return base::Bind(&StatusCallback, was_called, result); |
63 } | 63 } |
64 | 64 |
65 void FindCallback(bool* was_called, | 65 void FindCallback( |
66 ServiceWorkerStatusCode* result, | 66 bool* was_called, |
67 scoped_refptr<ServiceWorkerRegistration>* found, | 67 ServiceWorkerStatusCode* result, |
68 ServiceWorkerStatusCode status, | 68 scoped_refptr<ServiceWorkerRegistration>* found, |
69 scoped_refptr<ServiceWorkerRegistration> registration) { | 69 ServiceWorkerStatusCode status, |
| 70 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
70 *was_called = true; | 71 *was_called = true; |
71 *result = status; | 72 *result = status; |
72 *found = std::move(registration); | 73 *found = registration; |
73 } | 74 } |
74 | 75 |
75 ServiceWorkerStorage::FindRegistrationCallback MakeFindCallback( | 76 ServiceWorkerStorage::FindRegistrationCallback MakeFindCallback( |
76 bool* was_called, | 77 bool* was_called, |
77 ServiceWorkerStatusCode* result, | 78 ServiceWorkerStatusCode* result, |
78 scoped_refptr<ServiceWorkerRegistration>* found) { | 79 scoped_refptr<ServiceWorkerRegistration>* found) { |
79 return base::Bind(&FindCallback, was_called, result, found); | 80 return base::Bind(&FindCallback, was_called, result, found); |
80 } | 81 } |
81 | 82 |
82 void GetAllCallback( | 83 void GetAllCallback( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 storage()->GetUserDataForAllRegistrations( | 427 storage()->GetUserDataForAllRegistrations( |
427 key, base::Bind(&GetUserDataForAllRegistrationsCallback, &was_called, | 428 key, base::Bind(&GetUserDataForAllRegistrationsCallback, &was_called, |
428 data, &result)); | 429 data, &result)); |
429 EXPECT_FALSE(was_called); // always async | 430 EXPECT_FALSE(was_called); // always async |
430 base::RunLoop().RunUntilIdle(); | 431 base::RunLoop().RunUntilIdle(); |
431 EXPECT_TRUE(was_called); | 432 EXPECT_TRUE(was_called); |
432 return result; | 433 return result; |
433 } | 434 } |
434 | 435 |
435 ServiceWorkerStatusCode UpdateToActiveState( | 436 ServiceWorkerStatusCode UpdateToActiveState( |
436 scoped_refptr<ServiceWorkerRegistration> registration) { | 437 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
437 bool was_called = false; | 438 bool was_called = false; |
438 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; | 439 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; |
439 storage()->UpdateToActiveState(registration.get(), | 440 storage()->UpdateToActiveState(registration.get(), |
440 MakeStatusCallback(&was_called, &result)); | 441 MakeStatusCallback(&was_called, &result)); |
441 EXPECT_FALSE(was_called); // always async | 442 EXPECT_FALSE(was_called); // always async |
442 base::RunLoop().RunUntilIdle(); | 443 base::RunLoop().RunUntilIdle(); |
443 EXPECT_TRUE(was_called); | 444 EXPECT_TRUE(was_called); |
444 return result; | 445 return result; |
445 } | 446 } |
446 | 447 |
447 void UpdateLastUpdateCheckTime( | 448 void UpdateLastUpdateCheckTime( |
448 scoped_refptr<ServiceWorkerRegistration> registration) { | 449 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
449 storage()->UpdateLastUpdateCheckTime(registration.get()); | 450 storage()->UpdateLastUpdateCheckTime(registration.get()); |
450 base::RunLoop().RunUntilIdle(); | 451 base::RunLoop().RunUntilIdle(); |
451 } | 452 } |
452 | 453 |
453 ServiceWorkerStatusCode FindRegistrationForDocument( | 454 ServiceWorkerStatusCode FindRegistrationForDocument( |
454 const GURL& document_url, | 455 const GURL& document_url, |
455 scoped_refptr<ServiceWorkerRegistration>* registration) { | 456 scoped_refptr<ServiceWorkerRegistration>* registration) { |
456 bool was_called = false; | 457 bool was_called = false; |
457 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; | 458 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; |
458 storage()->FindRegistrationForDocument( | 459 storage()->FindRegistrationForDocument( |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 // Remove other registration at first origin. | 1738 // Remove other registration at first origin. |
1738 EXPECT_EQ(SERVICE_WORKER_OK, | 1739 EXPECT_EQ(SERVICE_WORKER_OK, |
1739 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); | 1740 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); |
1740 | 1741 |
1741 // No foreign fetch registrations remain. | 1742 // No foreign fetch registrations remain. |
1742 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); | 1743 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); |
1743 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); | 1744 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); |
1744 } | 1745 } |
1745 | 1746 |
1746 } // namespace content | 1747 } // namespace content |
OLD | NEW |