| 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/renderer/chrome_render_thread_observer.h" | 5 #include "chrome/renderer/chrome_render_thread_observer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/base_switches.h" | 15 #include "base/base_switches.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 19 #include "base/location.h" | 19 #include "base/location.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/metrics/field_trial.h" | 22 #include "base/metrics/field_trial.h" |
| 23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
| 24 #include "base/metrics/statistics_recorder.h" | 24 #include "base/metrics/statistics_recorder.h" |
| 25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
| 26 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
| 27 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/thread_task_runner_handle.h" | 29 #include "base/thread_task_runner_handle.h" |
| 29 #include "base/threading/platform_thread.h" | 30 #include "base/threading/platform_thread.h" |
| 30 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 31 #include "chrome/common/child_process_logging.h" | 32 #include "chrome/common/child_process_logging.h" |
| 32 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/media/media_resource_provider.h" | 34 #include "chrome/common/media/media_resource_provider.h" |
| 34 #include "chrome/common/net/net_resource_provider.h" | 35 #include "chrome/common/net/net_resource_provider.h" |
| 35 #include "chrome/common/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
| 36 #include "chrome/common/resource_usage_reporter.mojom.h" | 37 #include "chrome/common/resource_usage_reporter.mojom.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 327 } |
| 327 | 328 |
| 328 void ChromeRenderThreadObserver::OnSetContentSettingRules( | 329 void ChromeRenderThreadObserver::OnSetContentSettingRules( |
| 329 const RendererContentSettingRules& rules) { | 330 const RendererContentSettingRules& rules) { |
| 330 content_setting_rules_ = rules; | 331 content_setting_rules_ = rules; |
| 331 } | 332 } |
| 332 | 333 |
| 333 void ChromeRenderThreadObserver::OnSetFieldTrialGroup( | 334 void ChromeRenderThreadObserver::OnSetFieldTrialGroup( |
| 334 const std::string& field_trial_name, | 335 const std::string& field_trial_name, |
| 335 const std::string& group_name, | 336 const std::string& group_name, |
| 336 base::ProcessId sender_pid) { | 337 base::ProcessId sender_pid, |
| 338 int32_t debug_token) { |
| 337 // Check that the sender's PID doesn't change between messages. We expect | 339 // Check that the sender's PID doesn't change between messages. We expect |
| 338 // these IPCs to always be delivered from the same browser process, whose pid | 340 // these IPCs to always be delivered from the same browser process, whose pid |
| 339 // should not change. | 341 // should not change. |
| 340 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. | 342 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. |
| 341 static base::ProcessId sender_pid_cached = sender_pid; | 343 static base::ProcessId sender_pid_cached = sender_pid; |
| 342 CHECK_EQ(sender_pid_cached, sender_pid) << sender_pid_cached << "/" | 344 CHECK_EQ(sender_pid_cached, sender_pid) << sender_pid_cached << "/" |
| 343 << sender_pid; | 345 << sender_pid; |
| 346 // Check that the sender's debug_token doesn't change between messages. |
| 347 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. |
| 348 static int32_t debug_token_cached = debug_token; |
| 349 CHECK_EQ(debug_token_cached, debug_token) << debug_token_cached << "/" |
| 350 << debug_token; |
| 351 // The debug token should also correspond to what was specified on the |
| 352 // --force-fieldtrials command line for DebugToken trial. |
| 353 const std::string debug_token_trial_value = |
| 354 base::FieldTrialList::FindFullName("DebugToken"); |
| 355 if (!debug_token_trial_value.empty()) { |
| 356 CHECK_EQ(base::IntToString(debug_token), debug_token_trial_value) |
| 357 << debug_token << "/" << debug_token_trial_value; |
| 358 } |
| 359 |
| 344 base::FieldTrial* trial = | 360 base::FieldTrial* trial = |
| 345 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); | 361 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); |
| 346 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. | 362 // TODO(asvitkine): Remove this after http://crbug.com/359406 is fixed. |
| 347 if (!trial) { | 363 if (!trial) { |
| 348 // Log the --force-fieldtrials= switch value for debugging purposes. Take | 364 // Log the --force-fieldtrials= switch value for debugging purposes. Take |
| 349 // its substring starting with the trial name, since otherwise the end of | 365 // its substring starting with the trial name, since otherwise the end of |
| 350 // it can get truncated in the dump. | 366 // it can get truncated in the dump. |
| 351 std::string switch_substr = base::CommandLine::ForCurrentProcess()-> | 367 std::string switch_substr = base::CommandLine::ForCurrentProcess()-> |
| 352 GetSwitchValueASCII(switches::kForceFieldTrials); | 368 GetSwitchValueASCII(switches::kForceFieldTrials); |
| 353 size_t index = switch_substr.find(field_trial_name); | 369 size_t index = switch_substr.find(field_trial_name); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 370 ChromeRenderThreadObserver::content_setting_rules() const { | 386 ChromeRenderThreadObserver::content_setting_rules() const { |
| 371 return &content_setting_rules_; | 387 return &content_setting_rules_; |
| 372 } | 388 } |
| 373 | 389 |
| 374 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized( | 390 void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized( |
| 375 const std::string& trial_name, | 391 const std::string& trial_name, |
| 376 const std::string& group_name) { | 392 const std::string& group_name) { |
| 377 content::RenderThread::Get()->Send( | 393 content::RenderThread::Get()->Send( |
| 378 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); | 394 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); |
| 379 } | 395 } |
| OLD | NEW |