#include "base/allocator/allocator_extension.h"
#include "base/bind.h"
#include "base/command_line.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/field_trial.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/metrics/variations/variations_util.h"
#include "chrome/common/net/net_resource_provider.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/variations/variations_util.h"
#include "chrome/renderer/content_settings_observer.h"
-#include "chrome/renderer/extensions/extension_localization_peer.h"
#include "chrome/renderer/security_filter_peer.h"
#include "content/public/child/resource_dispatcher_delegate.h"
#include "content/public/renderer/render_thread.h"
#include "base/win/iat_patch_function.h"
#endif
+#if defined(ENABLE_EXTENSIONS)
+#include "chrome/renderer/extensions/extension_localization_peer.h"
+#endif
+
using blink::WebCache;
using blink::WebRuntimeFeatures;
using blink::WebSecurityPolicy;
namespace {
const int kCacheStatsDelayMS = 2000;
-const size_t kUnitializedCacheCapacity = UINT_MAX;
class RendererResourceDelegate : public content::ResourceDispatcherDelegate {
public:
: weak_factory_(this) {
}
- virtual webkit_glue::ResourceLoaderBridge::Peer* OnRequestComplete(
- webkit_glue::ResourceLoaderBridge::Peer* current_peer,
- ResourceType::Type resource_type,
- int error_code) OVERRIDE {
+ content::RequestPeer* OnRequestComplete(content::RequestPeer* current_peer,
+ content::ResourceType resource_type,
+ int error_code) override {
// Update the browser about our cache.
// Rate limit informing the host of our cache stats.
if (!weak_factory_.HasWeakPtrs()) {
resource_type, current_peer, error_code);
}
- virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse(
- webkit_glue::ResourceLoaderBridge::Peer* current_peer,
- const std::string& mime_type,
- const GURL& url) OVERRIDE {
+ content::RequestPeer* OnReceivedResponse(content::RequestPeer* current_peer,
+ const std::string& mime_type,
+ const GURL& url) override {
+#if defined(ENABLE_EXTENSIONS)
return ExtensionLocalizationPeer::CreateExtensionLocalizationPeer(
current_peer, RenderThread::Get(), mime_type, url);
+#else
+ return NULL;
+#endif
}
private:
ChromeRenderProcessObserver::ChromeRenderProcessObserver(
ChromeContentRendererClient* client)
: client_(client),
- clear_cache_pending_(false),
- webkit_initialized_(false),
- pending_cache_min_dead_capacity_(0),
- pending_cache_max_dead_capacity_(0),
- pending_cache_capacity_(kUnitializedCacheCapacity) {
+ webkit_initialized_(false) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kEnableWatchdog)) {
- // TODO(JAR): Need to implement renderer IO msgloop watchdog.
- }
#if defined(ENABLE_AUTOFILL_DIALOG)
- bool enable_autofill = !command_line.HasSwitch(
- autofill::switches::kDisableInteractiveAutocomplete);
- WebRuntimeFeatures::enableRequestAutocomplete(
- enable_autofill ||
- command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures));
+ WebRuntimeFeatures::enableRequestAutocomplete(true);
#endif
+ if (command_line.HasSwitch(switches::kEnableShowModalDialog))
+ WebRuntimeFeatures::enableShowModalDialog(true);
+
+ if (command_line.HasSwitch(switches::kJavaScriptHarmony)) {
+ std::string flag("--harmony");
+ v8::V8::SetFlagsFromString(flag.c_str(), static_cast<int>(flag.size()));
+ }
+
RenderThread* thread = RenderThread::Get();
resource_delegate_.reset(new RendererResourceDelegate());
thread->SetResourceDispatcherDelegate(resource_delegate_.get());
IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess,
OnSetIsIncognitoProcess)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup)
IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats)
IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats,
void ChromeRenderProcessObserver::WebKitInitialized() {
webkit_initialized_ = true;
- if (pending_cache_capacity_ != kUnitializedCacheCapacity) {
- WebCache::setCapacities(pending_cache_min_dead_capacity_,
- pending_cache_max_dead_capacity_,
- pending_cache_capacity_);
- }
-
// chrome-native: is a scheme used for placeholder navigations that allow
// UIs to be drawn with platform native widgets instead of HTML. These pages
// should not be accessible, and should also be treated as empty documents
content_setting_rules_ = rules;
}
-void ChromeRenderProcessObserver::OnSetCacheCapacities(size_t min_dead_capacity,
- size_t max_dead_capacity,
- size_t capacity) {
- if (!webkit_initialized_) {
- pending_cache_min_dead_capacity_ = min_dead_capacity;
- pending_cache_max_dead_capacity_ = max_dead_capacity;
- pending_cache_capacity_ = capacity;
- return;
- }
-
- WebCache::setCapacities(
- min_dead_capacity, max_dead_capacity, capacity);
-}
-
-void ChromeRenderProcessObserver::OnClearCache(bool on_navigation) {
- if (on_navigation || !webkit_initialized_) {
- clear_cache_pending_ = true;
- } else {
- WebCache::clear();
- }
-}
-
void ChromeRenderProcessObserver::OnGetCacheResourceStats() {
WebCache::ResourceTypeStats stats;
if (webkit_initialized_)
const std::string& group_name) {
base::FieldTrial* trial =
base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name);
+ // TODO(mef): Remove this check after the investigation of 359406 is complete.
+ CHECK(trial) << field_trial_name << ":" << group_name;
// Ensure the trial is marked as "used" by calling group() on it. This is
// needed to ensure the trial is properly reported in renderer crash reports.
trial->group();
HeapStatisticsCollector::Instance()->InitiateCollection();
}
-void ChromeRenderProcessObserver::ExecutePendingClearCache() {
- if (clear_cache_pending_ && webkit_initialized_) {
- clear_cache_pending_ = false;
- WebCache::clear();
- }
-}
-
const RendererContentSettingRules*
ChromeRenderProcessObserver::content_setting_rules() const {
return &content_setting_rules_;