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

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

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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 <vector> 12 #include <vector>
13 13
14 #include "base/atomic_sequence_num.h" 14 #include "base/atomic_sequence_num.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "content/browser/message_port_message_filter.h" 20 #include "content/browser/message_port_message_filter.h"
21 #include "content/browser/shared_worker/shared_worker_message_filter.h" 21 #include "content/browser/shared_worker/shared_worker_message_filter.h"
22 #include "content/browser/shared_worker/worker_storage_partition.h" 22 #include "content/browser/shared_worker/worker_storage_partition.h"
23 #include "content/common/message_port_messages.h" 23 #include "content/common/message_port_messages.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/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
27 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
28 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
29 #include "ipc/ipc_sync_message.h" 30 #include "ipc/ipc_sync_message.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
32 namespace content { 33 namespace content {
33 34
34 class SharedWorkerServiceImplTest : public testing::Test { 35 class SharedWorkerServiceImplTest : public testing::Test {
35 public: 36 public:
36 static void RegisterRunningProcessID(int process_id) { 37 static void RegisterRunningProcessID(int process_id) {
37 base::AutoLock lock(s_lock_); 38 base::AutoLock lock(s_lock_);
38 s_running_process_id_set_.insert(process_id); 39 s_running_process_id_set_.insert(process_id);
39 } 40 }
40 static void UnregisterRunningProcessID(int process_id) { 41 static void UnregisterRunningProcessID(int process_id) {
41 base::AutoLock lock(s_lock_); 42 base::AutoLock lock(s_lock_);
42 s_running_process_id_set_.erase(process_id); 43 s_running_process_id_set_.erase(process_id);
43 } 44 }
44 45
45 protected: 46 protected:
46 SharedWorkerServiceImplTest() 47 SharedWorkerServiceImplTest()
47 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), 48 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
48 browser_context_(new TestBrowserContext()), 49 browser_context_(new TestBrowserContext()),
49 partition_( 50 partition_(new WorkerStoragePartition(
50 new WorkerStoragePartition(browser_context_->GetRequestContext(), 51 BrowserContext::GetDefaultStoragePartition(browser_context_.get())->
51 NULL, 52 GetURLRequestContext(),
52 NULL, 53 NULL,
53 NULL, 54 NULL,
54 NULL, 55 NULL,
55 NULL, 56 NULL,
56 NULL, 57 NULL,
57 NULL)) { 58 NULL,
59 NULL)) {
58 SharedWorkerServiceImpl::GetInstance() 60 SharedWorkerServiceImpl::GetInstance()
59 ->ChangeUpdateWorkerDependencyFuncForTesting( 61 ->ChangeUpdateWorkerDependencyFuncForTesting(
60 &SharedWorkerServiceImplTest::MockUpdateWorkerDependency); 62 &SharedWorkerServiceImplTest::MockUpdateWorkerDependency);
61 SharedWorkerServiceImpl::GetInstance() 63 SharedWorkerServiceImpl::GetInstance()
62 ->ChangeTryIncrementWorkerRefCountFuncForTesting( 64 ->ChangeTryIncrementWorkerRefCountFuncForTesting(
63 &SharedWorkerServiceImplTest::MockTryIncrementWorkerRefCount); 65 &SharedWorkerServiceImplTest::MockTryIncrementWorkerRefCount);
64 } 66 }
65 67
66 void SetUp() override {} 68 void SetUp() override {}
67 void TearDown() override { 69 void TearDown() override {
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 kDocumentIDs[2], 918 kDocumentIDs[2],
917 kRenderFrameRouteIDs[2]); 919 kRenderFrameRouteIDs[2]);
918 EXPECT_NE(MSG_ROUTING_NONE, connector2->route_id()); 920 EXPECT_NE(MSG_ROUTING_NONE, connector2->route_id());
919 EXPECT_EQ(0U, renderer_host2->QueuedMessageCount()); 921 EXPECT_EQ(0U, renderer_host2->QueuedMessageCount());
920 RunAllPendingInMessageLoop(); 922 RunAllPendingInMessageLoop();
921 EXPECT_EQ(1U, renderer_host2->QueuedMessageCount()); 923 EXPECT_EQ(1U, renderer_host2->QueuedMessageCount());
922 CheckViewMsgWorkerCreated(renderer_host2.get(), connector2.get()); 924 CheckViewMsgWorkerCreated(renderer_host2.get(), connector2.get());
923 } 925 }
924 926
925 } // namespace content 927 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/shared_worker/shared_worker_instance_unittest.cc ('k') | content/browser/tracing/tracing_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698