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