#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/renderer/chrome_content_renderer_client.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 "net/base/net_errors.h"
#include "net/base/net_module.h"
#include "third_party/WebKit/public/web/WebCache.h"
-#include "third_party/WebKit/public/web/WebCrossOriginPreflightResultCache.h"
#include "third_party/WebKit/public/web/WebDocument.h"
-#include "third_party/WebKit/public/web/WebFontCache.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebView.h"
-#include "third_party/sqlite/sqlite3.h"
-#include "v8/include/v8.h"
#if defined(OS_WIN)
#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::WebCrossOriginPreflightResultCache;
-using blink::WebFontCache;
using blink::WebRuntimeFeatures;
using blink::WebSecurityPolicy;
using blink::WebString;
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,
+ virtual 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.
resource_type, current_peer, error_code);
}
- virtual webkit_glue::ResourceLoaderBridge::Peer* OnReceivedResponse(
- webkit_glue::ResourceLoaderBridge::Peer* current_peer,
+ virtual 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());
#elif defined(OS_WIN)
// crypt32.dll is used to decode X509 certificates for Chromoting.
// Only load this library when the feature is enabled.
- std::string error;
- base::LoadNativeLibrary(base::FilePath(L"crypt32.dll"), &error);
+ base::LoadNativeLibrary(base::FilePath(L"crypt32.dll"), NULL);
#endif
// Setup initial set of crash dump data for Field Trials in this renderer.
chrome_variations::SetChildProcessLoggingVariationList();
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,
OnGetCacheResourceStats)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules,
OnSetContentSettingRules)
IPC_MESSAGE_UNHANDLED(handled = false)
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::OnPurgeMemory() {
- if (!webkit_initialized_)
- return;
-
- // Clear the object cache (as much as possible; some live objects cannot be
- // freed).
- WebCache::clear();
-
- // Clear the font/glyph cache.
- WebFontCache::clear();
-
- // Clear the Cross-Origin Preflight cache.
- WebCrossOriginPreflightResultCache::clear();
-
- // Release all freeable memory from the SQLite process-global page cache (a
- // low-level object which backs the Connection-specific page caches).
- while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) {
- }
-
- v8::V8::LowMemoryNotification();
-
- // Tell our allocator to release any free pages it's still holding.
- base::allocator::ReleaseFreeMemory();
-
- if (client_)
- client_->OnPurgeMemory();
-}
-
-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_;