| 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 "content/browser/gpu/gpu_data_manager_impl.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 6 | 6 |
| 7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
| 8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
| 9 #endif // OS_MACOSX | 9 #endif // OS_MACOSX |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/string_piece.h" | 17 #include "base/string_piece.h" |
| 18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "base/version.h" | 21 #include "base/version.h" |
| 22 #include "content/browser/gpu/gpu_process_host.h" | 22 #include "content/browser/gpu/gpu_process_host.h" |
| 23 #include "content/browser/gpu/gpu_util.h" | 23 #include "content/browser/gpu/gpu_util.h" |
| 24 #include "content/common/gpu/gpu_messages.h" | 24 #include "content/common/gpu/gpu_messages.h" |
| 25 #include "content/gpu/gpu_info_collector.h" | 25 #include "content/gpu/gpu_info_collector.h" |
| 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/gpu_data_manager_observer.h" | 27 #include "content/public/browser/gpu_data_manager_observer.h" |
| 27 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
| 28 #include "content/public/common/content_constants.h" | 29 #include "content/public/common/content_constants.h" |
| 29 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
| 30 #include "grit/content_resources.h" | 31 #include "grit/content_resources.h" |
| 31 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/gl/gl_implementation.h" | 33 #include "ui/gl/gl_implementation.h" |
| 33 #include "ui/gl/gl_switches.h" | 34 #include "ui/gl/gl_switches.h" |
| 34 #include "ui/gl/gpu_switching_manager.h" | 35 #include "ui/gl/gpu_switching_manager.h" |
| 35 #include "webkit/plugins/plugin_switches.h" | 36 #include "webkit/plugins/plugin_switches.h" |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 554 |
| 554 return true; | 555 return true; |
| 555 } | 556 } |
| 556 #endif | 557 #endif |
| 557 | 558 |
| 558 void GpuDataManagerImpl::BlockDomainFrom3DAPIs( | 559 void GpuDataManagerImpl::BlockDomainFrom3DAPIs( |
| 559 const GURL& url, DomainGuilt guilt) { | 560 const GURL& url, DomainGuilt guilt) { |
| 560 BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); | 561 BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); |
| 561 } | 562 } |
| 562 | 563 |
| 563 GpuDataManagerImpl::DomainBlockStatus | 564 bool GpuDataManagerImpl::Are3DAPIsBlocked(const GURL& url, |
| 564 GpuDataManagerImpl::Are3DAPIsBlocked(const GURL& url) const { | 565 int render_process_id, |
| 565 return Are3DAPIsBlockedAtTime(url, base::Time::Now()); | 566 int render_view_id, |
| 567 ThreeDAPIType requester) { |
| 568 bool blocked = Are3DAPIsBlockedAtTime(url, base::Time::Now()) != |
| 569 GpuDataManagerImpl::DOMAIN_BLOCK_STATUS_NOT_BLOCKED; |
| 570 if (blocked) { |
| 571 BrowserThread::PostTask( |
| 572 BrowserThread::UI, FROM_HERE, |
| 573 base::Bind(&GpuDataManagerImpl::Notify3DAPIBlocked, |
| 574 base::Unretained(this), url, render_process_id, |
| 575 render_view_id, requester)); |
| 576 } |
| 577 |
| 578 return blocked; |
| 566 } | 579 } |
| 567 | 580 |
| 568 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() { | 581 void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() { |
| 569 domain_blocking_enabled_ = false; | 582 domain_blocking_enabled_ = false; |
| 570 } | 583 } |
| 571 | 584 |
| 572 GpuDataManagerImpl::GpuDataManagerImpl() | 585 GpuDataManagerImpl::GpuDataManagerImpl() |
| 573 : complete_gpu_info_already_requested_(false), | 586 : complete_gpu_info_already_requested_(false), |
| 574 blacklisted_features_(GPU_FEATURE_TYPE_UNKNOWN), | 587 blacklisted_features_(GPU_FEATURE_TYPE_UNKNOWN), |
| 575 preliminary_blacklisted_features_(GPU_FEATURE_TYPE_UNKNOWN), | 588 preliminary_blacklisted_features_(GPU_FEATURE_TYPE_UNKNOWN), |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 BLOCK_STATUS_NOT_BLOCKED, | 788 BLOCK_STATUS_NOT_BLOCKED, |
| 776 BLOCK_STATUS_MAX); | 789 BLOCK_STATUS_MAX); |
| 777 | 790 |
| 778 return DOMAIN_BLOCK_STATUS_NOT_BLOCKED; | 791 return DOMAIN_BLOCK_STATUS_NOT_BLOCKED; |
| 779 } | 792 } |
| 780 | 793 |
| 781 int64 GpuDataManagerImpl::GetBlockAllDomainsDurationInMs() const { | 794 int64 GpuDataManagerImpl::GetBlockAllDomainsDurationInMs() const { |
| 782 return kBlockAllDomainsMs; | 795 return kBlockAllDomainsMs; |
| 783 } | 796 } |
| 784 | 797 |
| 798 void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url, |
| 799 int render_process_id, |
| 800 int render_view_id, |
| 801 ThreeDAPIType requester) { |
| 802 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
| 803 url, render_process_id, render_view_id, requester); |
| 804 } |
| 805 |
| 785 } // namespace content | 806 } // namespace content |
| OLD | NEW |