| Index: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
 | 
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
 | 
| index d38e6ccfb0438278a3ef60a1d04628207d2d40ba..7c178f92e957a916aaaa2bc39b0934728b41cad6 100644
 | 
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
 | 
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
 | 
| @@ -18,6 +18,7 @@
 | 
|  #include "platform/ThreadSafeFunctional.h"
 | 
|  #include "platform/TraceEvent.h"
 | 
|  #include "public/platform/Platform.h"
 | 
| +#include "public/platform/WebScheduler.h"
 | 
|  #include "wtf/MainThread.h"
 | 
|  #include "wtf/text/TextEncodingRegistry.h"
 | 
|  
 | 
| @@ -162,7 +163,7 @@ private:
 | 
|  class SourceStream : public v8::ScriptCompiler::ExternalSourceStream {
 | 
|      WTF_MAKE_NONCOPYABLE(SourceStream);
 | 
|  public:
 | 
| -    SourceStream()
 | 
| +    explicit SourceStream(WebTaskRunner* loadingTaskRunner)
 | 
|          : v8::ScriptCompiler::ExternalSourceStream()
 | 
|          , m_cancelled(false)
 | 
|          , m_finished(false)
 | 
| @@ -170,6 +171,7 @@ public:
 | 
|          , m_queueTailPosition(0)
 | 
|          , m_bookmarkPosition(0)
 | 
|          , m_lengthOfBOM(0)
 | 
| +        , m_loadingTaskRunner(adoptPtr(loadingTaskRunner->clone()))
 | 
|      {
 | 
|      }
 | 
|  
 | 
| @@ -219,7 +221,7 @@ public:
 | 
|          }
 | 
|  
 | 
|          // Inform main thread to re-queue the data.
 | 
| -        Platform::current()->mainThread()->taskRunner()->postTask(
 | 
| +        m_loadingTaskRunner->postTask(
 | 
|              FROM_HERE, bind(&SourceStream::fetchDataFromResourceBuffer, this, 0));
 | 
|      }
 | 
|  
 | 
| @@ -370,16 +372,18 @@ private:
 | 
|      // We store this separately, to avoid having to guard all
 | 
|      // m_queueLeadPosition references with a mutex.
 | 
|      unsigned m_lengthOfBOM; // Used by both threads; guarded by m_mutex.
 | 
| +
 | 
| +    OwnPtr<WebTaskRunner> m_loadingTaskRunner;
 | 
|  };
 | 
|  
 | 
|  size_t ScriptStreamer::kSmallScriptThreshold = 30 * 1024;
 | 
|  
 | 
| -void ScriptStreamer::startStreaming(PendingScript& script, PendingScript::Type scriptType, Settings* settings, ScriptState* scriptState)
 | 
| +void ScriptStreamer::startStreaming(PendingScript& script, PendingScript::Type scriptType, Settings* settings, ScriptState* scriptState, WebTaskRunner* loadingTaskRunner)
 | 
|  {
 | 
|      // We don't yet know whether the script will really be streamed. E.g.,
 | 
|      // suppressing streaming for short scripts is done later. Record only the
 | 
|      // sure negative cases here.
 | 
| -    bool startedStreaming = startStreamingInternal(script, scriptType, settings, scriptState);
 | 
| +    bool startedStreaming = startStreamingInternal(script, scriptType, settings, scriptState, loadingTaskRunner);
 | 
|      if (!startedStreaming)
 | 
|          Platform::current()->histogramEnumeration(startedStreamingHistogramName(scriptType), 0, 2);
 | 
|  }
 | 
| @@ -421,7 +425,7 @@ void ScriptStreamer::streamingCompleteOnBackgroundThread()
 | 
|  
 | 
|      // notifyFinished might already be called, or it might be called in the
 | 
|      // future (if the parsing finishes earlier because of a parse error).
 | 
| -    Platform::current()->mainThread()->taskRunner()->postTask(FROM_HERE, threadSafeBind(&ScriptStreamer::streamingComplete, AllowCrossThreadAccess(this)));
 | 
| +    m_loadingTaskRunner->postTask(FROM_HERE, threadSafeBind(&ScriptStreamer::streamingComplete, AllowCrossThreadAccess(this)));
 | 
|  
 | 
|      // The task might delete ScriptStreamer, so it's not safe to do anything
 | 
|      // after posting it. Note that there's no way to guarantee that this
 | 
| @@ -513,7 +517,7 @@ void ScriptStreamer::notifyAppendData(ScriptResource* resource)
 | 
|  
 | 
|          ASSERT(!m_stream);
 | 
|          ASSERT(!m_source);
 | 
| -        m_stream = new SourceStream();
 | 
| +        m_stream = new SourceStream(m_loadingTaskRunner.get());
 | 
|          // m_source takes ownership of m_stream.
 | 
|          m_source = adoptPtr(new v8::ScriptCompiler::StreamedSource(m_stream, m_encoding));
 | 
|  
 | 
| @@ -564,7 +568,7 @@ void ScriptStreamer::notifyFinished(Resource* resource)
 | 
|      notifyFinishedToClient();
 | 
|  }
 | 
|  
 | 
| -ScriptStreamer::ScriptStreamer(ScriptResource* resource, PendingScript::Type scriptType, ScriptState* scriptState, v8::ScriptCompiler::CompileOptions compileOptions)
 | 
| +ScriptStreamer::ScriptStreamer(ScriptResource* resource, PendingScript::Type scriptType, ScriptState* scriptState, v8::ScriptCompiler::CompileOptions compileOptions, WebTaskRunner* loadingTaskRunner)
 | 
|      : m_resource(resource)
 | 
|      , m_detached(false)
 | 
|      , m_stream(0)
 | 
| @@ -577,6 +581,7 @@ ScriptStreamer::ScriptStreamer(ScriptResource* resource, PendingScript::Type scr
 | 
|      , m_scriptState(scriptState)
 | 
|      , m_scriptType(scriptType)
 | 
|      , m_encoding(v8::ScriptCompiler::StreamedSource::TWO_BYTE) // Unfortunately there's no dummy encoding value in the enum; let's use one we don't stream.
 | 
| +    , m_loadingTaskRunner(adoptPtr(loadingTaskRunner->clone()))
 | 
|  {
 | 
|  }
 | 
|  
 | 
| @@ -632,7 +637,7 @@ void ScriptStreamer::notifyFinishedToClient()
 | 
|          m_client->notifyFinished(m_resource);
 | 
|  }
 | 
|  
 | 
| -bool ScriptStreamer::startStreamingInternal(PendingScript& script, PendingScript::Type scriptType, Settings* settings, ScriptState* scriptState)
 | 
| +bool ScriptStreamer::startStreamingInternal(PendingScript& script, PendingScript::Type scriptType, Settings* settings, ScriptState* scriptState, WebTaskRunner* loadingTaskRunner)
 | 
|  {
 | 
|      ASSERT(isMainThread());
 | 
|      ASSERT(scriptState->contextIsValid());
 | 
| @@ -665,7 +670,7 @@ bool ScriptStreamer::startStreamingInternal(PendingScript& script, PendingScript
 | 
|      // The Resource might go out of scope if the script is no longer
 | 
|      // needed. This makes PendingScript notify the ScriptStreamer when it is
 | 
|      // destroyed.
 | 
| -    script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState, compileOption));
 | 
| +    script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState, compileOption, loadingTaskRunner));
 | 
|  
 | 
|      return true;
 | 
|  }
 | 
| 
 |