OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/task_runner_util.h" | 15 #include "base/task_runner_util.h" |
16 #include "content/browser/background_sync/background_sync_manager.h" | 16 #include "content/browser/background_sync/background_sync_manager.h" |
17 #include "content/browser/background_sync/background_sync_network_observer.h" | 17 #include "content/browser/background_sync/background_sync_network_observer.h" |
18 #include "content/browser/background_sync/background_sync_registration_handle.h" | |
19 #include "content/browser/background_sync/background_sync_status.h" | 18 #include "content/browser/background_sync/background_sync_status.h" |
20 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 19 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
21 #include "content/browser/service_worker/service_worker_registration.h" | 20 #include "content/browser/service_worker/service_worker_registration.h" |
22 #include "content/public/browser/background_sync_context.h" | 21 #include "content/public/browser/background_sync_context.h" |
23 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
24 #include "content/public/browser/storage_partition.h" | 23 #include "content/public/browser/storage_partition.h" |
25 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
26 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
27 #include "content/public/test/background_sync_test_util.h" | 26 #include "content/public/test/background_sync_test_util.h" |
28 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 bool* result_out, | 62 bool* result_out, |
64 bool result) { | 63 bool result) { |
65 *result_out = result; | 64 *result_out = result; |
66 task_runner->PostTask(FROM_HERE, quit); | 65 task_runner->PostTask(FROM_HERE, quit); |
67 } | 66 } |
68 | 67 |
69 void RegistrationPendingDidGetSyncRegistration( | 68 void RegistrationPendingDidGetSyncRegistration( |
70 const std::string& tag, | 69 const std::string& tag, |
71 const base::Callback<void(bool)>& callback, | 70 const base::Callback<void(bool)>& callback, |
72 BackgroundSyncStatus error_type, | 71 BackgroundSyncStatus error_type, |
73 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> | 72 scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) { |
74 registration_handles) { | |
75 ASSERT_EQ(BACKGROUND_SYNC_STATUS_OK, error_type); | 73 ASSERT_EQ(BACKGROUND_SYNC_STATUS_OK, error_type); |
76 // Find the right registration in the list and check its status. | 74 // Find the right registration in the list and check its status. |
77 for (const auto& handle : *registration_handles) { | 75 for (const BackgroundSyncRegistration* registration : *registrations) { |
78 if (handle->options()->tag == tag) { | 76 if (registration->options()->tag == tag) { |
79 callback.Run(handle->sync_state() == BackgroundSyncState::PENDING); | 77 callback.Run(registration->sync_state() == BackgroundSyncState::PENDING); |
80 return; | 78 return; |
81 } | 79 } |
82 } | 80 } |
83 ADD_FAILURE() << "Registration should exist"; | 81 ADD_FAILURE() << "Registration should exist"; |
84 } | 82 } |
85 | 83 |
86 void RegistrationPendingDidGetSWRegistration( | 84 void RegistrationPendingDidGetSWRegistration( |
87 const scoped_refptr<BackgroundSyncContext> sync_context, | 85 const scoped_refptr<BackgroundSyncContext> sync_context, |
88 const std::string& tag, | 86 const std::string& tag, |
89 const base::Callback<void(bool)>& callback, | 87 const base::Callback<void(bool)>& callback, |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 std::string script_result; | 657 std::string script_result; |
660 GURL url = alt_server.GetURL(kRegisterSyncURL); | 658 GURL url = alt_server.GetURL(kRegisterSyncURL); |
661 EXPECT_TRUE(RunScript( | 659 EXPECT_TRUE(RunScript( |
662 BuildScriptString("registerFromCrossOriginServiceWorker", url.spec()), | 660 BuildScriptString("registerFromCrossOriginServiceWorker", url.spec()), |
663 &script_result)); | 661 &script_result)); |
664 EXPECT_EQ(BuildExpectedResult("worker", "failed to register sync"), | 662 EXPECT_EQ(BuildExpectedResult("worker", "failed to register sync"), |
665 script_result); | 663 script_result); |
666 } | 664 } |
667 | 665 |
668 } // namespace content | 666 } // namespace content |
OLD | NEW |