Put headers in right order.  Ensure WebKit is initialized everywhere necessary.  Remove unnecessary V8::IsDead() check (IdleNotification() already checks IsRunning(), which is mutually exclusive with IsDead()).

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/265019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28360 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 87a7cf64..09b043ab 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -44,8 +44,8 @@
 #include "chrome/renderer/renderer_webkitclient_impl.h"
 #include "chrome/renderer/user_script_slave.h"
 #include "ipc/ipc_message.h"
-#include "webkit/api/public/WebColor.h"
 #include "webkit/api/public/WebCache.h"
+#include "webkit/api/public/WebColor.h"
 #include "webkit/api/public/WebKit.h"
 #include "webkit/api/public/WebStorageEventDispatcher.h"
 #include "webkit/api/public/WebString.h"
@@ -317,7 +317,7 @@
 // views.
 void RenderThread::OnSetCSSColors(
     const std::vector<CSSColors::CSSColorMapping>& colors) {
-
+  EnsureWebKitInitialized();
   size_t num_colors = colors.size();
   scoped_array<WebKit::WebColorName> color_names(
       new WebKit::WebColorName[num_colors]);
@@ -338,7 +338,6 @@
                                    const WebPreferences& webkit_prefs,
                                    int32 view_id) {
   EnsureWebKitInitialized();
-
   // When bringing in render_view, also bring in webkit's glue and jsbindings.
   RenderView::Create(
       this, parent_hwnd, MSG_ROUTING_NONE, renderer_prefs,
@@ -486,10 +485,8 @@
   MallocExtension::instance()->ReleaseFreeMemory();
 #endif
 
-  if (!v8::V8::IsDead()) {
-    LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this;
-    v8::V8::IdleNotification();
-  }
+  LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this;
+  v8::V8::IdleNotification();
 
   // Schedule next invocation.
   // Dampen the delay using the algorithm:
@@ -513,6 +510,7 @@
 }
 
 void RenderThread::OnPurgePluginListCache(bool reload_pages) {
+  EnsureWebKitInitialized();
   // The call below will cause a GetPlugins call with refresh=true, but at this
   // point we already know that the browser has refreshed its list, so disable
   // refresh temporarily to prevent each renderer process causing the list to be