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

Side by Side Diff: content/browser/shared_worker/shared_worker_service_impl_unittest.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shared_worker/shared_worker_service_impl.h" 5 #include "content/browser/shared_worker/shared_worker_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <tuple> 13 #include <tuple>
14 14
15 #include "base/atomic_sequence_num.h" 15 #include "base/atomic_sequence_num.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/run_loop.h"
18 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
21 #include "base/synchronization/waitable_event.h"
22 #include "content/browser/shared_worker/shared_worker_message_filter.h" 22 #include "content/browser/shared_worker/shared_worker_message_filter.h"
23 #include "content/browser/shared_worker/worker_storage_partition.h" 23 #include "content/browser/shared_worker/worker_storage_partition.h"
24 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
25 #include "content/common/worker_messages.h" 25 #include "content/common/worker_messages.h"
26 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
27 #include "content/public/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
28 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
29 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
30 #include "ipc/ipc_sync_message.h" 30 #include "ipc/ipc_sync_message.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 base::Lock SharedWorkerServiceImplTest::s_lock_; 105 base::Lock SharedWorkerServiceImplTest::s_lock_;
106 std::set<int> SharedWorkerServiceImplTest::s_running_process_id_set_; 106 std::set<int> SharedWorkerServiceImplTest::s_running_process_id_set_;
107 107
108 namespace { 108 namespace {
109 109
110 static const int kProcessIDs[] = {100, 101, 102}; 110 static const int kProcessIDs[] = {100, 101, 102};
111 static const unsigned long long kDocumentIDs[] = {200, 201, 202}; 111 static const unsigned long long kDocumentIDs[] = {200, 201, 202};
112 static const int kRenderFrameRouteIDs[] = {300, 301, 302}; 112 static const int kRenderFrameRouteIDs[] = {300, 301, 302};
113 113
114 void BlockingReadFromMessagePort(MessagePort port, base::string16* message) { 114 void BlockingReadFromMessagePort(MessagePort port, base::string16* message) {
115 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL, 115 base::RunLoop run_loop;
116 base::WaitableEvent::InitialState::NOT_SIGNALED); 116 port.SetCallback(run_loop.QuitClosure());
117 port.SetCallback( 117 run_loop.Run();
118 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)));
119 event.Wait();
120 118
121 std::vector<MessagePort> should_be_empty; 119 std::vector<MessagePort> should_be_empty;
122 EXPECT_TRUE(port.GetMessage(message, &should_be_empty)); 120 EXPECT_TRUE(port.GetMessage(message, &should_be_empty));
123 EXPECT_TRUE(should_be_empty.empty()); 121 EXPECT_TRUE(should_be_empty.empty());
124 } 122 }
125 123
126 class MockSharedWorkerMessageFilter : public SharedWorkerMessageFilter { 124 class MockSharedWorkerMessageFilter : public SharedWorkerMessageFilter {
127 public: 125 public:
128 MockSharedWorkerMessageFilter( 126 MockSharedWorkerMessageFilter(
129 int render_process_id, 127 int render_process_id,
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 kDocumentIDs[2], 892 kDocumentIDs[2],
895 kRenderFrameRouteIDs[2]); 893 kRenderFrameRouteIDs[2]);
896 EXPECT_NE(MSG_ROUTING_NONE, connector2->route_id()); 894 EXPECT_NE(MSG_ROUTING_NONE, connector2->route_id());
897 EXPECT_EQ(0U, renderer_host2->QueuedMessageCount()); 895 EXPECT_EQ(0U, renderer_host2->QueuedMessageCount());
898 RunAllPendingInMessageLoop(); 896 RunAllPendingInMessageLoop();
899 EXPECT_EQ(1U, renderer_host2->QueuedMessageCount()); 897 EXPECT_EQ(1U, renderer_host2->QueuedMessageCount());
900 CheckViewMsgWorkerCreated(renderer_host2.get(), connector2.get()); 898 CheckViewMsgWorkerCreated(renderer_host2.get(), connector2.get());
901 } 899 }
902 900
903 } // namespace content 901 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/mojo_async_resource_handler.cc ('k') | content/child/url_response_body_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698