OLD | NEW |
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/devtools/embedded_worker_devtools_manager.h" | 5 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
11 #include "content/browser/devtools/devtools_agent_host_impl.h" | 11 #include "content/browser/devtools/devtools_agent_host_impl.h" |
12 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h" | 12 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h" |
13 #include "content/browser/shared_worker/shared_worker_instance.h" | 13 #include "content/browser/shared_worker/shared_worker_instance.h" |
14 #include "content/browser/shared_worker/worker_storage_partition.h" | 14 #include "content/browser/shared_worker/worker_storage_partition.h" |
15 #include "content/public/test/test_browser_context.h" | 15 #include "content/public/test/test_browser_context.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 namespace { | 19 namespace { |
20 | 20 |
21 class TestDevToolsClientHost : public DevToolsAgentHostClient { | 21 class TestDevToolsClientHost : public DevToolsAgentHostClient { |
22 public: | 22 public: |
23 TestDevToolsClientHost() {} | 23 TestDevToolsClientHost() {} |
24 virtual ~TestDevToolsClientHost() {} | 24 virtual ~TestDevToolsClientHost() {} |
25 virtual void DispatchProtocolMessage( | 25 virtual void DispatchProtocolMessage( |
26 DevToolsAgentHost* agent_host, const std::string& message) OVERRIDE {} | 26 DevToolsAgentHost* agent_host, const std::string& message) override {} |
27 virtual void AgentHostClosed( | 27 virtual void AgentHostClosed( |
28 DevToolsAgentHost* agent_host, bool replaced) OVERRIDE {} | 28 DevToolsAgentHost* agent_host, bool replaced) override {} |
29 | 29 |
30 void InspectAgentHost(DevToolsAgentHost* agent_host) { | 30 void InspectAgentHost(DevToolsAgentHost* agent_host) { |
31 if (agent_host_.get()) | 31 if (agent_host_.get()) |
32 agent_host_->DetachClient(); | 32 agent_host_->DetachClient(); |
33 agent_host_ = agent_host; | 33 agent_host_ = agent_host; |
34 if (agent_host_.get()) | 34 if (agent_host_.get()) |
35 agent_host_->AttachClient(this); | 35 agent_host_->AttachClient(this); |
36 } | 36 } |
37 private: | 37 private: |
38 scoped_refptr<DevToolsAgentHost> agent_host_; | 38 scoped_refptr<DevToolsAgentHost> agent_host_; |
(...skipping 13 matching lines...) Expand all Loading... |
52 NULL, | 52 NULL, |
53 NULL, | 53 NULL, |
54 NULL, | 54 NULL, |
55 NULL, | 55 NULL, |
56 NULL, | 56 NULL, |
57 NULL, | 57 NULL, |
58 NULL)), | 58 NULL)), |
59 partition_id_(*partition_.get()) {} | 59 partition_id_(*partition_.get()) {} |
60 | 60 |
61 protected: | 61 protected: |
62 virtual void SetUp() OVERRIDE { | 62 virtual void SetUp() override { |
63 manager_ = EmbeddedWorkerDevToolsManager::GetInstance(); | 63 manager_ = EmbeddedWorkerDevToolsManager::GetInstance(); |
64 } | 64 } |
65 virtual void TearDown() OVERRIDE { | 65 virtual void TearDown() override { |
66 EmbeddedWorkerDevToolsManager::GetInstance()->ResetForTesting(); | 66 EmbeddedWorkerDevToolsManager::GetInstance()->ResetForTesting(); |
67 } | 67 } |
68 | 68 |
69 void CheckWorkerState(int worker_process_id, | 69 void CheckWorkerState(int worker_process_id, |
70 int worker_route_id, | 70 int worker_route_id, |
71 WorkerState state) { | 71 WorkerState state) { |
72 const EmbeddedWorkerDevToolsManager::WorkerId id(worker_process_id, | 72 const EmbeddedWorkerDevToolsManager::WorkerId id(worker_process_id, |
73 worker_route_id); | 73 worker_route_id); |
74 EmbeddedWorkerDevToolsManager::AgentHostMap::iterator it = | 74 EmbeddedWorkerDevToolsManager::AgentHostMap::iterator it = |
75 manager_->workers_.find(id); | 75 manager_->workers_.find(id); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 manager_->SharedWorkerCreated(3, 2, instance); | 302 manager_->SharedWorkerCreated(3, 2, instance); |
303 CheckWorkerState(3, 2, WorkerState::WORKER_UNINSPECTED); | 303 CheckWorkerState(3, 2, WorkerState::WORKER_UNINSPECTED); |
304 agent_host = NULL; | 304 agent_host = NULL; |
305 CheckWorkerState(3, 2, WorkerState::WORKER_UNINSPECTED); | 305 CheckWorkerState(3, 2, WorkerState::WORKER_UNINSPECTED); |
306 manager_->WorkerDestroyed(3, 2); | 306 manager_->WorkerDestroyed(3, 2); |
307 CheckWorkerNotExist(3, 2); | 307 CheckWorkerNotExist(3, 2); |
308 CheckWorkerCount(0); | 308 CheckWorkerCount(0); |
309 } | 309 } |
310 | 310 |
311 } // namespace content | 311 } // namespace content |
OLD | NEW |