OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/chromedriver/commands.h" | 5 #include "chrome/test/chromedriver/commands.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 SessionThreadMap* session_thread_map, | 106 SessionThreadMap* session_thread_map, |
107 const base::DictionaryValue& params, | 107 const base::DictionaryValue& params, |
108 const std::string& session_id, | 108 const std::string& session_id, |
109 const CommandCallback& callback) { | 109 const CommandCallback& callback) { |
110 | 110 |
111 size_t get_remaining_count = session_thread_map->size(); | 111 size_t get_remaining_count = session_thread_map->size(); |
112 base::WeakPtrFactory<size_t> weak_ptr_factory(&get_remaining_count); | 112 base::WeakPtrFactory<size_t> weak_ptr_factory(&get_remaining_count); |
113 scoped_ptr<base::ListValue> session_list(new base::ListValue()); | 113 scoped_ptr<base::ListValue> session_list(new base::ListValue()); |
114 | 114 |
115 if (!get_remaining_count) { | 115 if (!get_remaining_count) { |
116 callback.Run(Status(kOk), session_list.Pass(), session_id); | 116 callback.Run(Status(kOk), std::move(session_list), session_id); |
117 return; | 117 return; |
118 } | 118 } |
119 | 119 |
120 base::RunLoop run_loop; | 120 base::RunLoop run_loop; |
121 | 121 |
122 for (SessionThreadMap::const_iterator iter = session_thread_map->begin(); | 122 for (SessionThreadMap::const_iterator iter = session_thread_map->begin(); |
123 iter != session_thread_map->end(); | 123 iter != session_thread_map->end(); |
124 ++iter) { | 124 ++iter) { |
125 session_capabilities_command.Run(params, | 125 session_capabilities_command.Run(params, |
126 iter->first, | 126 iter->first, |
127 base::Bind( | 127 base::Bind( |
128 &OnGetSession, | 128 &OnGetSession, |
129 weak_ptr_factory.GetWeakPtr(), | 129 weak_ptr_factory.GetWeakPtr(), |
130 run_loop.QuitClosure(), | 130 run_loop.QuitClosure(), |
131 session_list.get())); | 131 session_list.get())); |
132 } | 132 } |
133 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 133 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
134 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(10)); | 134 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(10)); |
135 base::MessageLoop::current()->SetNestableTasksAllowed(true); | 135 base::MessageLoop::current()->SetNestableTasksAllowed(true); |
136 run_loop.Run(); | 136 run_loop.Run(); |
137 | 137 |
138 callback.Run(Status(kOk), session_list.Pass(), session_id); | 138 callback.Run(Status(kOk), std::move(session_list), session_id); |
139 } | 139 } |
140 | 140 |
141 namespace { | 141 namespace { |
142 | 142 |
143 void OnSessionQuit(const base::WeakPtr<size_t>& quit_remaining_count, | 143 void OnSessionQuit(const base::WeakPtr<size_t>& quit_remaining_count, |
144 const base::Closure& all_quit_func, | 144 const base::Closure& all_quit_func, |
145 const Status& status, | 145 const Status& status, |
146 scoped_ptr<base::Value> value, | 146 scoped_ptr<base::Value> value, |
147 const std::string& session_id) { | 147 const std::string& session_id) { |
148 // |quit_remaining_count| may no longer be valid if a timeout occurred. | 148 // |quit_remaining_count| may no longer be valid if a timeout occurred. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 namespace internal { | 318 namespace internal { |
319 | 319 |
320 void CreateSessionOnSessionThreadForTesting(const std::string& id) { | 320 void CreateSessionOnSessionThreadForTesting(const std::string& id) { |
321 SetThreadLocalSession(make_scoped_ptr(new Session(id))); | 321 SetThreadLocalSession(make_scoped_ptr(new Session(id))); |
322 } | 322 } |
323 | 323 |
324 } // namespace internal | 324 } // namespace internal |
OLD | NEW |