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

Side by Side Diff: content/browser/devtools/protocol/system_info_handler.cc

Issue 1408363004: [DevTools] Filter any messages from previous sessions in DevToolsAgentHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/devtools/protocol/system_info_handler.h" 5 #include "content/browser/devtools/protocol/system_info_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/gpu/compositor_util.h" 8 #include "content/browser/gpu/compositor_util.h"
9 #include "content/public/browser/gpu_data_manager.h" 9 #include "content/public/browser/gpu_data_manager.h"
10 #include "gpu/config/gpu_info.h" 10 #include "gpu/config/gpu_info.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 } // namespace 88 } // namespace
89 89
90 class SystemInfoHandlerGpuObserver : public content::GpuDataManagerObserver { 90 class SystemInfoHandlerGpuObserver : public content::GpuDataManagerObserver {
91 public: 91 public:
92 SystemInfoHandlerGpuObserver(base::WeakPtr<SystemInfoHandler> handler, 92 SystemInfoHandlerGpuObserver(base::WeakPtr<SystemInfoHandler> handler,
93 DevToolsCommandId command_id) 93 DevToolsCommandId command_id)
94 : handler_(handler), 94 : handler_(handler),
95 command_id_(command_id), 95 command_id_(command_id),
96 observer_id_(++next_observer_id_) 96 observer_id_(++next_observer_id_) {
97 {
98 if (handler_) { 97 if (handler_) {
99 handler_->AddActiveObserverId(observer_id_); 98 handler_->AddActiveObserverId(observer_id_);
100 } 99 }
101 } 100 }
102 101
103 void OnGpuInfoUpdate() override { 102 void OnGpuInfoUpdate() override {
104 UnregisterAndSendResponse(); 103 UnregisterAndSendResponse();
105 } 104 }
106 105
107 void OnGpuProcessCrashed(base::TerminationStatus exit_code) override { 106 void OnGpuProcessCrashed(base::TerminationStatus exit_code) override {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 std::string reason; 146 std::string reason;
148 if (!GpuDataManager::GetInstance()->GpuAccessAllowed(&reason) || 147 if (!GpuDataManager::GetInstance()->GpuAccessAllowed(&reason) ||
149 GpuDataManager::GetInstance()->IsEssentialGpuInfoAvailable()) { 148 GpuDataManager::GetInstance()->IsEssentialGpuInfoAvailable()) {
150 // The GpuDataManager already has all of the information needed to make 149 // The GpuDataManager already has all of the information needed to make
151 // GPU-based blacklisting decisions. Post a task to give it to the 150 // GPU-based blacklisting decisions. Post a task to give it to the
152 // client asynchronously. 151 // client asynchronously.
153 // 152 //
154 // Waiting for complete GPU info in the if-test above seems to 153 // Waiting for complete GPU info in the if-test above seems to
155 // frequently hit internal timeouts in the launching of the unsandboxed 154 // frequently hit internal timeouts in the launching of the unsandboxed
156 // GPU process in debug builds on Windows. 155 // GPU process in debug builds on Windows.
157 BrowserThread::PostTask( 156 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
158 BrowserThread::UI, 157 base::Bind(&SystemInfoHandler::SendGetInfoResponse,
159 FROM_HERE, 158 weak_factory_.GetWeakPtr(), command_id));
160 base::Bind(&SystemInfoHandler::SendGetInfoResponse,
161 weak_factory_.GetWeakPtr(),
162 command_id));
163 } else { 159 } else {
164 // We will be able to get more information from the GpuDataManager. 160 // We will be able to get more information from the GpuDataManager.
165 // Register a transient observer with it to call us back when the 161 // Register a transient observer with it to call us back when the
166 // information is available. 162 // information is available.
167 SystemInfoHandlerGpuObserver* observer = new SystemInfoHandlerGpuObserver( 163 SystemInfoHandlerGpuObserver* observer = new SystemInfoHandlerGpuObserver(
168 weak_factory_.GetWeakPtr(), command_id); 164 weak_factory_.GetWeakPtr(), command_id);
169 BrowserThread::PostDelayedTask( 165 BrowserThread::PostDelayedTask(
170 BrowserThread::UI, 166 BrowserThread::UI, FROM_HERE,
171 FROM_HERE,
172 base::Bind(&SystemInfoHandler::ObserverWatchdogCallback, 167 base::Bind(&SystemInfoHandler::ObserverWatchdogCallback,
173 weak_factory_.GetWeakPtr(), 168 weak_factory_.GetWeakPtr(), observer->GetObserverId(),
174 observer->GetObserverId(),
175 command_id), 169 command_id),
176 base::TimeDelta::FromMilliseconds(kGPUInfoWatchdogTimeoutMs)); 170 base::TimeDelta::FromMilliseconds(kGPUInfoWatchdogTimeoutMs));
177 GpuDataManager::GetInstance()->AddObserver(observer); 171 GpuDataManager::GetInstance()->AddObserver(observer);
178 // There's no other method available to request just essential GPU info. 172 // There's no other method available to request just essential GPU info.
179 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded(); 173 GpuDataManager::GetInstance()->RequestCompleteGpuInfoIfNeeded();
180 } 174 }
181 175
182 return Response::OK(); 176 return Response::OK();
183 } 177 }
184 178
185 void SystemInfoHandler::SendGetInfoResponse(DevToolsCommandId command_id) { 179 void SystemInfoHandler::SendGetInfoResponse(DevToolsCommandId command_id) {
186 gpu::GPUInfo gpu_info = GpuDataManager::GetInstance()->GetGPUInfo(); 180 gpu::GPUInfo gpu_info = GpuDataManager::GetInstance()->GetGPUInfo();
187 std::vector<scoped_refptr<GPUDevice>> devices; 181 std::vector<scoped_refptr<GPUDevice>> devices;
188 devices.push_back(GPUDeviceToProtocol(gpu_info.gpu)); 182 devices.push_back(GPUDeviceToProtocol(gpu_info.gpu));
189 for (const auto& device : gpu_info.secondary_gpus) 183 for (const auto& device : gpu_info.secondary_gpus)
190 devices.push_back(GPUDeviceToProtocol(device)); 184 devices.push_back(GPUDeviceToProtocol(device));
191 185
192 scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue); 186 scoped_ptr<base::DictionaryValue> aux_attributes(new base::DictionaryValue);
193 AuxGPUInfoEnumerator enumerator(aux_attributes.get()); 187 AuxGPUInfoEnumerator enumerator(aux_attributes.get());
194 gpu_info.EnumerateFields(&enumerator); 188 gpu_info.EnumerateFields(&enumerator);
195 189
196 scoped_refptr<GPUInfo> gpu = GPUInfo::Create() 190 scoped_refptr<GPUInfo> gpu = GPUInfo::Create()
197 ->set_devices(devices) 191 ->set_devices(devices)
198 ->set_aux_attributes(aux_attributes.Pass()) 192 ->set_aux_attributes(aux_attributes.Pass())
199 ->set_feature_status(make_scoped_ptr(GetFeatureStatus())) 193 ->set_feature_status(make_scoped_ptr(GetFeatureStatus()))
200 ->set_driver_bug_workarounds(GetDriverBugWorkarounds()); 194 ->set_driver_bug_workarounds(GetDriverBugWorkarounds());
201 195
202 client_->SendGetInfoResponse( 196 client_->SendGetInfoResponse(
203 command_id, 197 command_id, GetInfoResponse::Create()
204 GetInfoResponse::Create()->set_gpu(gpu) 198 ->set_gpu(gpu)
205 ->set_model_name(gpu_info.machine_model_name) 199 ->set_model_name(gpu_info.machine_model_name)
206 ->set_model_version(gpu_info.machine_model_version)); 200 ->set_model_version(gpu_info.machine_model_version));
207 } 201 }
208 202
209 void SystemInfoHandler::AddActiveObserverId(int observer_id) { 203 void SystemInfoHandler::AddActiveObserverId(int observer_id) {
210 base::AutoLock auto_lock(lock_); 204 base::AutoLock auto_lock(lock_);
211 active_observers_.insert(observer_id); 205 active_observers_.insert(observer_id);
212 } 206 }
213 207
214 bool SystemInfoHandler::RemoveActiveObserverId(int observer_id) { 208 bool SystemInfoHandler::RemoveActiveObserverId(int observer_id) {
215 base::AutoLock auto_lock(lock_); 209 base::AutoLock auto_lock(lock_);
216 int num_removed = active_observers_.erase(observer_id); 210 int num_removed = active_observers_.erase(observer_id);
217 return (num_removed != 0); 211 return (num_removed != 0);
218 } 212 }
219 213
220 void SystemInfoHandler::ObserverWatchdogCallback(int observer_id, 214 void SystemInfoHandler::ObserverWatchdogCallback(int observer_id,
221 DevToolsCommandId command_id) { 215 DevToolsCommandId command_id) {
222 DCHECK_CURRENTLY_ON(BrowserThread::UI); 216 DCHECK_CURRENTLY_ON(BrowserThread::UI);
223 if (RemoveActiveObserverId(observer_id)) { 217 if (RemoveActiveObserverId(observer_id)) {
224 SendGetInfoResponse(command_id); 218 SendGetInfoResponse(command_id);
225 // For the time being we want to know about this event in the test logs. 219 // For the time being we want to know about this event in the test logs.
226 LOG(ERROR) << "SystemInfoHandler: request for GPU info timed out!" 220 LOG(ERROR) << "SystemInfoHandler: request for GPU info timed out!"
227 << " Most recent info sent."; 221 << " Most recent info sent.";
228 } 222 }
229 } 223 }
230 224
231 } // namespace system_info 225 } // namespace system_info
232 } // namespace devtools 226 } // namespace devtools
233 } // namespace content 227 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698