diff --git a/DEPS b/DEPS
index 33053eb..6a75b93 100644
--- a/DEPS
+++ b/DEPS
@@ -327,7 +327,7 @@
   },
 
   'src/third_party/depot_tools':
-    Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'f2cb0f5b3ea5ba5ccd899494163ca7b264c7d445',
+    Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'ebe839b6bfc3e9276b8d1e42a0d6e830bb04899e',
 
   # DevTools node modules. Used on Linux buildbots only.
   'src/third_party/devtools-node-modules': {
diff --git a/chrome/VERSION b/chrome/VERSION
index e1dd217..f1e35a64 100644
--- a/chrome/VERSION
+++ b/chrome/VERSION
@@ -1,4 +1,4 @@
 MAJOR=65
 MINOR=0
-BUILD=3302
+BUILD=3303
 PATCH=0
diff --git a/media/remoting/remoting_cdm_controller.cc b/media/remoting/remoting_cdm_controller.cc
index d036c27..35282626 100644
--- a/media/remoting/remoting_cdm_controller.cc
+++ b/media/remoting/remoting_cdm_controller.cc
@@ -35,7 +35,8 @@
 void RemotingCdmController::OnSessionStateChanged() {
   DCHECK(thread_checker_.CalledOnValidThread());
 
-  if (is_remoting_ && session_->state() == SharedSession::SESSION_STOPPING) {
+  if (is_remoting_ && session_->state() != SharedSession::SESSION_STARTING &&
+      session_->state() != SharedSession::SESSION_STARTED) {
     session_->Shutdown();
     is_remoting_ = false;
   }
diff --git a/media/remoting/renderer_controller.cc b/media/remoting/renderer_controller.cc
index e4a1dfc..9aa78ec 100644
--- a/media/remoting/renderer_controller.cc
+++ b/media/remoting/renderer_controller.cc
@@ -37,6 +37,35 @@
 // can feel "janky" to the user.
 constexpr double kMinRemotingMediaDurationInSec = 60;
 
+StopTrigger GetStopTrigger(mojom::RemotingStopReason reason) {
+  switch (reason) {
+    case mojom::RemotingStopReason::ROUTE_TERMINATED:
+      return ROUTE_TERMINATED;
+    case mojom::RemotingStopReason::SOURCE_GONE:
+      return MEDIA_ELEMENT_DESTROYED;
+    case mojom::RemotingStopReason::MESSAGE_SEND_FAILED:
+      return MESSAGE_SEND_FAILED;
+    case mojom::RemotingStopReason::DATA_SEND_FAILED:
+      return DATA_SEND_FAILED;
+    case mojom::RemotingStopReason::UNEXPECTED_FAILURE:
+      return UNEXPECTED_FAILURE;
+    case mojom::RemotingStopReason::SERVICE_GONE:
+      return SERVICE_GONE;
+    case mojom::RemotingStopReason::USER_DISABLED:
+      return USER_DISABLED;
+    case mojom::RemotingStopReason::LOCAL_PLAYBACK:
+      // This RemotingStopReason indicates the RendererController initiated the
+      // session shutdown in the immediate past, and the trigger for that should
+      // have already been recorded in the metrics. Here, this is just duplicate
+      // feedback from the sink for that same event. Return UNKNOWN_STOP_TRIGGER
+      // because this reason can not be a stop trigger and it would be a logic
+      // flaw for this value to be recorded in the metrics.
+      return UNKNOWN_STOP_TRIGGER;
+  }
+
+  return UNKNOWN_STOP_TRIGGER;  // To suppress compiler warning on Windows.
+}
+
 }  // namespace
 
 RendererController::RendererController(scoped_refptr<SharedSession> session)
@@ -72,7 +101,8 @@
 
 void RendererController::OnSessionStateChanged() {
   DCHECK(thread_checker_.CalledOnValidThread());
-  UpdateFromSessionState(SINK_AVAILABLE, ROUTE_TERMINATED);
+  UpdateFromSessionState(SINK_AVAILABLE,
+                         GetStopTrigger(session_->get_last_stop_reason()));
 }
 
 void RendererController::UpdateFromSessionState(StartTrigger start_trigger,
diff --git a/media/remoting/renderer_controller_unittest.cc b/media/remoting/renderer_controller_unittest.cc
index 10465d7d..374e9dc 100644
--- a/media/remoting/renderer_controller_unittest.cc
+++ b/media/remoting/renderer_controller_unittest.cc
@@ -484,6 +484,7 @@
   EXPECT_NE(SharedSession::SESSION_PERMANENTLY_STOPPED,
             controller_->session()->state());
   cdm_shared_session->OnSinkGone();
+  cdm_shared_session->OnStopped(mojom::RemotingStopReason::ROUTE_TERMINATED);
   RunUntilIdle();
   EXPECT_EQ(SharedSession::SESSION_PERMANENTLY_STOPPED,
             controller_->session()->state());
@@ -534,6 +535,7 @@
   EXPECT_FALSE(IsInDelayedStart());
 
   cdm_shared_session->OnSinkGone();
+  cdm_shared_session->OnStopped(mojom::RemotingStopReason::ROUTE_TERMINATED);
   RunUntilIdle();
   EXPECT_FALSE(is_rendering_remotely_);
   EXPECT_NE(SharedSession::SESSION_PERMANENTLY_STOPPED,
diff --git a/media/remoting/shared_session.cc b/media/remoting/shared_session.cc
index bd48b07..45f93a2 100644
--- a/media/remoting/shared_session.cc
+++ b/media/remoting/shared_session.cc
@@ -88,19 +88,11 @@
 void SharedSession::OnSinkGone() {
   DCHECK(thread_checker_.CalledOnValidThread());
 
+  // Prevent the clients to start any future remoting sessions. Won't affect the
+  // behavior of the currently-running session (if any).
   sink_metadata_ = mojom::RemotingSinkMetadata();
-
-  if (state_ == SESSION_PERMANENTLY_STOPPED)
-    return;
-  if (state_ == SESSION_CAN_START) {
-    UpdateAndNotifyState(SESSION_UNAVAILABLE);
-    return;
-  }
-  if (state_ == SESSION_STARTED || state_ == SESSION_STARTING) {
-    VLOG(1) << "Sink is gone in a remoting session.";
-    // Remoting is being stopped by Remoter.
-    UpdateAndNotifyState(SESSION_STOPPING);
-  }
+  if (state_ == SESSION_CAN_START)
+    state_ = SESSION_UNAVAILABLE;
 }
 
 void SharedSession::OnStarted() {
@@ -133,8 +125,10 @@
   DCHECK(thread_checker_.CalledOnValidThread());
 
   VLOG(1) << "Remoting stopped: " << reason;
+  stop_reason_ = reason;
   if (state_ == SESSION_PERMANENTLY_STOPPED)
     return;
+  // This call will stop the current remoting session if started.
   UpdateAndNotifyState(SESSION_UNAVAILABLE);
 }
 
diff --git a/media/remoting/shared_session.h b/media/remoting/shared_session.h
index 5d222bc0..ccbb1ac 100644
--- a/media/remoting/shared_session.h
+++ b/media/remoting/shared_session.h
@@ -88,6 +88,11 @@
     return state_;
   }
 
+  // Get the last stop reason reported by OnStopped().
+  mojom::RemotingStopReason get_last_stop_reason() const {
+    return stop_reason_;
+  }
+
   const std::string& sink_name() const { return sink_metadata_.friendly_name; }
 
   // Queries on remoting sink capabilities.
@@ -169,6 +174,9 @@
   // RemoveClient() before they are gone.
   std::vector<Client*> clients_;
 
+  mojom::RemotingStopReason stop_reason_ =
+      mojom::RemotingStopReason::LOCAL_PLAYBACK;
+
   // This is used to check all the methods are called on the current thread in
   // debug builds.
   base::ThreadChecker thread_checker_;
diff --git a/media/remoting/triggers.h b/media/remoting/triggers.h
index af07d7a..5c2b7ec 100644
--- a/media/remoting/triggers.h
+++ b/media/remoting/triggers.h
@@ -72,8 +72,17 @@
   DATA_PIPE_CREATE_ERROR = 17,  // Mojo data pipe creation failed (OOM?).
   MOJO_PIPE_ERROR = 18,         // Mojo message/data pipe operation failed.
 
+  // Message/Data sending errors forcing shutdown.
+  MESSAGE_SEND_FAILED = 19,  // Failed to send a RPC message to the sink.
+  DATA_SEND_FAILED = 20,     // Failed to pull from pipe or send to the sink.
+  UNEXPECTED_FAILURE = 21,   // Unexpected failure or inconsistent state.
+  SERVICE_GONE = 22,         // Mirror service disconnected.
+
+  // User changing setting forcing shutdown.
+  USER_DISABLED = 23,  // Media Remoting was disabled by user.
+
   // Change this to the highest value.
-  STOP_TRIGGER_MAX = 18,
+  STOP_TRIGGER_MAX = 23,
 };
 
 }  // namespace remoting
diff --git a/third_party/WebKit/Source/bindings/core/v8/BUILD.gn b/third_party/WebKit/Source/bindings/core/v8/BUILD.gn
index a1b68e9..d064a31 100644
--- a/third_party/WebKit/Source/bindings/core/v8/BUILD.gn
+++ b/third_party/WebKit/Source/bindings/core/v8/BUILD.gn
@@ -64,8 +64,6 @@
   "$bindings_core_v8_output_dir/node_or_string.h",
   "$bindings_core_v8_output_dir/radio_node_list_or_element.cc",
   "$bindings_core_v8_output_dir/radio_node_list_or_element.h",
-  "$bindings_core_v8_output_dir/request_or_usv_string.cc",
-  "$bindings_core_v8_output_dir/request_or_usv_string.h",
   "$bindings_core_v8_output_dir/scroll_into_view_options_or_boolean.cc",
   "$bindings_core_v8_output_dir/scroll_into_view_options_or_boolean.h",
   "$bindings_core_v8_output_dir/string_or_array_buffer.cc",
diff --git a/third_party/WebKit/Source/bindings/modules/v8/generated.gni b/third_party/WebKit/Source/bindings/modules/v8/generated.gni
index 5fd6d68..1118887 100644
--- a/third_party/WebKit/Source/bindings/modules/v8/generated.gni
+++ b/third_party/WebKit/Source/bindings/modules/v8/generated.gni
@@ -56,6 +56,8 @@
   "$bindings_modules_v8_output_dir/rtc_ice_candidate_init_or_rtc_ice_candidate.h",
   "$bindings_modules_v8_output_dir/rendering_context.cc",
   "$bindings_modules_v8_output_dir/rendering_context.h",
+  "$bindings_modules_v8_output_dir/request_or_usv_string.cc",
+  "$bindings_modules_v8_output_dir/request_or_usv_string.h",
   "$bindings_modules_v8_output_dir/request_or_usv_string_or_request_or_usv_string_sequence.cc",
   "$bindings_modules_v8_output_dir/request_or_usv_string_or_request_or_usv_string_sequence.h",
   "$bindings_modules_v8_output_dir/string_or_array_buffer_or_nfc_message.cc",
diff --git a/third_party/WebKit/Source/bindings/modules/v8/wasm/WasmResponseExtensions.cpp b/third_party/WebKit/Source/bindings/modules/v8/wasm/WasmResponseExtensions.cpp
index 3fd444c..af8b9d4 100644
--- a/third_party/WebKit/Source/bindings/modules/v8/wasm/WasmResponseExtensions.cpp
+++ b/third_party/WebKit/Source/bindings/modules/v8/wasm/WasmResponseExtensions.cpp
@@ -8,7 +8,7 @@
 #include "bindings/core/v8/ExceptionState.h"
 #include "bindings/core/v8/ScriptPromise.h"
 #include "bindings/core/v8/ScriptPromiseResolver.h"
-#include "bindings/core/v8/V8Response.h"
+#include "bindings/modules/v8/V8Response.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/FetchDataLoader.h"
diff --git a/third_party/WebKit/Source/core/BUILD.gn b/third_party/WebKit/Source/core/BUILD.gn
index 70f1ce74..b81457c 100644
--- a/third_party/WebKit/Source/core/BUILD.gn
+++ b/third_party/WebKit/Source/core/BUILD.gn
@@ -1768,12 +1768,9 @@
     "fetch/DataConsumerHandleTestUtil.h",
     "fetch/FetchDataLoaderTest.cpp",
     "fetch/FetchHeaderListTest.cpp",
-    "fetch/FetchResponseDataTest.cpp",
     "fetch/FormDataBytesConsumerTest.cpp",
     "fetch/MultipartParserTest.cpp",
     "fetch/ReadableStreamBytesConsumerTest.cpp",
-    "fetch/RequestTest.cpp",
-    "fetch/ResponseTest.cpp",
     "fileapi/FileListTest.cpp",
     "fileapi/FileTest.cpp",
     "frame/BrowserControlsTest.cpp",
diff --git a/third_party/WebKit/Source/core/core_idl_files.gni b/third_party/WebKit/Source/core/core_idl_files.gni
index a40f5218..0b8b8b8 100644
--- a/third_party/WebKit/Source/core/core_idl_files.gni
+++ b/third_party/WebKit/Source/core/core_idl_files.gni
@@ -167,8 +167,6 @@
                     "events/WheelEvent.idl",
                     "fetch/Body.idl",
                     "fetch/Headers.idl",
-                    "fetch/Request.idl",
-                    "fetch/Response.idl",
                     "fileapi/Blob.idl",
                     "fileapi/File.idl",
                     "fileapi/FileList.idl",
@@ -528,6 +526,7 @@
                     "dom/CommonDefinitions.idl",
                     "timing/DOMHighResTimeStamp.idl",
                     "timing/PerformanceEntryList.idl",
+                    "workers/RequestCredentials.idl",
                   ],
                   "abspath")
 
@@ -587,7 +586,6 @@
                     "events/TransitionEventInit.idl",
                     "events/UIEventInit.idl",
                     "events/WheelEventInit.idl",
-                    "fetch/ResponseInit.idl",
                     "fileapi/BlobPropertyBag.idl",
                     "fileapi/FilePropertyBag.idl",
                     "frame/ScrollIntoViewOptions.idl",
diff --git a/third_party/WebKit/Source/core/fetch/BUILD.gn b/third_party/WebKit/Source/core/fetch/BUILD.gn
index 3355dd6..b2bef16 100644
--- a/third_party/WebKit/Source/core/fetch/BUILD.gn
+++ b/third_party/WebKit/Source/core/fetch/BUILD.gn
@@ -20,12 +20,16 @@
     "FetchDataLoader.h",
     "FetchHeaderList.cpp",
     "FetchHeaderList.h",
-    "FetchManager.cpp",
-    "FetchManager.h",
-    "FetchRequestData.cpp",
-    "FetchRequestData.h",
-    "FetchResponseData.cpp",
-    "FetchResponseData.h",
+
+    # TODO(nhiroki): Move these files from modules/fetch to core/fetch.
+    # (https://crbug.com/794837)
+    # "FetchManager.cpp",
+    # "FetchManager.h",
+    # "FetchRequestData.cpp",
+    # "FetchRequestData.h",
+    # "FetchResponseData.cpp",
+    # "FetchResponseData.h",
+
     "FormDataBytesConsumer.cpp",
     "FormDataBytesConsumer.h",
 
@@ -40,16 +44,19 @@
     "MultipartParser.h",
     "ReadableStreamBytesConsumer.cpp",
     "ReadableStreamBytesConsumer.h",
-    "Request.cpp",
-    "Request.h",
-    "RequestInit.cpp",
-    "RequestInit.h",
-    "Response.cpp",
-    "Response.h",
+
+    # TODO(nhiroki): Move these files from modules/fetch to core/fetch.
+    # (https://crbug.com/794837)
+    # "Request.cpp",
+    # "Request.h",
+    # "RequestInit.cpp",
+    # "RequestInit.h",
+    # "Response.cpp",
+    # "Response.h",
   ]
 
   if (is_win && is_component_build) {
-    # Body.cpp exports a class (CORE_EXPORT) that inherits from
+    # Body.cpp exports a class (MODULES_EXPORT) that inherits from
     # PairIterable<String, String> that is also used as base class by an
     # imported (CORE_EXPORT) class and that confuses the Windows
     # linker/compiler. https://crbug.com/739340
diff --git a/third_party/WebKit/Source/core/fetch/FetchManager.cpp b/third_party/WebKit/Source/core/fetch/FetchManager.cpp
deleted file mode 100644
index be11fc4c..0000000
--- a/third_party/WebKit/Source/core/fetch/FetchManager.cpp
+++ /dev/null
@@ -1,883 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "core/fetch/FetchManager.h"
-
-#include <memory>
-#include "bindings/core/v8/ExceptionState.h"
-#include "bindings/core/v8/ScriptPromiseResolver.h"
-#include "core/dom/ExecutionContext.h"
-#include "core/fetch/Body.h"
-#include "core/fetch/BodyStreamBuffer.h"
-#include "core/fetch/BytesConsumer.h"
-#include "core/fetch/BytesConsumerForDataConsumerHandle.h"
-#include "core/fetch/FetchRequestData.h"
-#include "core/fetch/FormDataBytesConsumer.h"
-#include "core/fetch/Response.h"
-#include "core/fetch/ResponseInit.h"
-#include "core/fileapi/Blob.h"
-#include "core/frame/Frame.h"
-#include "core/frame/csp/ContentSecurityPolicy.h"
-#include "core/inspector/ConsoleMessage.h"
-#include "core/loader/SubresourceIntegrityHelper.h"
-#include "core/loader/ThreadableLoader.h"
-#include "core/loader/ThreadableLoaderClient.h"
-#include "core/page/ChromeClient.h"
-#include "core/page/Page.h"
-#include "core/probe/CoreProbes.h"
-#include "core/typed_arrays/DOMArrayBuffer.h"
-#include "platform/bindings/ScriptState.h"
-#include "platform/bindings/V8ThrowException.h"
-#include "platform/exported/WrappedResourceResponse.h"
-#include "platform/loader/SubresourceIntegrity.h"
-#include "platform/loader/fetch/FetchUtils.h"
-#include "platform/loader/fetch/ResourceError.h"
-#include "platform/loader/fetch/ResourceLoaderOptions.h"
-#include "platform/loader/fetch/ResourceRequest.h"
-#include "platform/loader/fetch/ResourceResponse.h"
-#include "platform/network/NetworkUtils.h"
-#include "platform/network/http_names.h"
-#include "platform/weborigin/KURL.h"
-#include "platform/weborigin/SchemeRegistry.h"
-#include "platform/weborigin/SecurityOrigin.h"
-#include "platform/weborigin/SecurityPolicy.h"
-#include "platform/wtf/HashSet.h"
-#include "platform/wtf/Vector.h"
-#include "platform/wtf/text/WTFString.h"
-#include "public/platform/WebCORS.h"
-#include "public/platform/WebURLRequest.h"
-#include "services/network/public/interfaces/fetch_api.mojom-blink.h"
-
-namespace blink {
-
-namespace {
-
-class SRIBytesConsumer final : public BytesConsumer {
- public:
-  // BytesConsumer implementation
-  Result BeginRead(const char** buffer, size_t* available) override {
-    if (!underlying_) {
-      *buffer = nullptr;
-      *available = 0;
-      return is_cancelled_ ? Result::kDone : Result::kShouldWait;
-    }
-    return underlying_->BeginRead(buffer, available);
-  }
-  Result EndRead(size_t read_size) override {
-    DCHECK(underlying_);
-    return underlying_->EndRead(read_size);
-  }
-  scoped_refptr<BlobDataHandle> DrainAsBlobDataHandle(
-      BlobSizePolicy policy) override {
-    return underlying_ ? underlying_->DrainAsBlobDataHandle(policy) : nullptr;
-  }
-  scoped_refptr<EncodedFormData> DrainAsFormData() override {
-    return underlying_ ? underlying_->DrainAsFormData() : nullptr;
-  }
-  void SetClient(BytesConsumer::Client* client) override {
-    DCHECK(!client_);
-    DCHECK(client);
-    if (underlying_)
-      underlying_->SetClient(client);
-    else
-      client_ = client;
-  }
-  void ClearClient() override {
-    if (underlying_)
-      underlying_->ClearClient();
-    else
-      client_ = nullptr;
-  }
-  void Cancel() override {
-    if (underlying_) {
-      underlying_->Cancel();
-    } else {
-      is_cancelled_ = true;
-      client_ = nullptr;
-    }
-  }
-  PublicState GetPublicState() const override {
-    return underlying_ ? underlying_->GetPublicState()
-                       : is_cancelled_ ? PublicState::kClosed
-                                       : PublicState::kReadableOrWaiting;
-  }
-  Error GetError() const override {
-    DCHECK(underlying_);
-    // We must not be in the errored state until we get updated.
-    return underlying_->GetError();
-  }
-  String DebugName() const override { return "SRIBytesConsumer"; }
-
-  // This function can be called at most once.
-  void Update(BytesConsumer* consumer) {
-    DCHECK(!underlying_);
-    if (is_cancelled_) {
-      // This consumer has already been closed.
-      return;
-    }
-
-    underlying_ = consumer;
-    if (client_) {
-      Client* client = client_;
-      client_ = nullptr;
-      underlying_->SetClient(client);
-      if (GetPublicState() != PublicState::kReadableOrWaiting)
-        client->OnStateChange();
-    }
-  }
-
-  void Trace(blink::Visitor* visitor) override {
-    visitor->Trace(underlying_);
-    visitor->Trace(client_);
-    BytesConsumer::Trace(visitor);
-  }
-
- private:
-  Member<BytesConsumer> underlying_;
-  Member<Client> client_;
-  bool is_cancelled_ = false;
-};
-
-}  // namespace
-
-class FetchManager::Loader final
-    : public GarbageCollectedFinalized<FetchManager::Loader>,
-      public ThreadableLoaderClient {
-  USING_PRE_FINALIZER(FetchManager::Loader, Dispose);
-
- public:
-  static Loader* Create(ExecutionContext* execution_context,
-                        FetchManager* fetch_manager,
-                        ScriptPromiseResolver* resolver,
-                        FetchRequestData* request,
-                        bool is_isolated_world) {
-    return new Loader(execution_context, fetch_manager, resolver, request,
-                      is_isolated_world);
-  }
-
-  ~Loader() override;
-  virtual void Trace(blink::Visitor*);
-
-  void DidReceiveRedirectTo(const KURL&) override;
-  void DidReceiveResponse(unsigned long,
-                          const ResourceResponse&,
-                          std::unique_ptr<WebDataConsumerHandle>) override;
-  void DidFinishLoading(unsigned long, double) override;
-  void DidFail(const ResourceError&) override;
-  void DidFailRedirectCheck() override;
-
-  void Start();
-  void Dispose();
-
-  class SRIVerifier final : public GarbageCollectedFinalized<SRIVerifier>,
-                            public WebDataConsumerHandle::Client {
-   public:
-    // Promptly clear m_handle and m_reader.
-    EAGERLY_FINALIZE();
-    // SRIVerifier takes ownership of |handle| and |response|.
-    // |updater| must be garbage collected. The other arguments
-    // all must have the lifetime of the give loader.
-    SRIVerifier(std::unique_ptr<WebDataConsumerHandle> handle,
-                SRIBytesConsumer* updater,
-                Response* response,
-                FetchManager::Loader* loader,
-                String integrity_metadata,
-                const KURL& url)
-        : handle_(std::move(handle)),
-          updater_(updater),
-          response_(response),
-          loader_(loader),
-          integrity_metadata_(integrity_metadata),
-          url_(url),
-          finished_(false) {
-      reader_ = handle_->ObtainReader(this);
-    }
-
-    void Cancel() {
-      reader_ = nullptr;
-      handle_ = nullptr;
-    }
-
-    void DidGetReadable() override {
-      DCHECK(reader_);
-      DCHECK(loader_);
-      DCHECK(response_);
-
-      WebDataConsumerHandle::Result r = WebDataConsumerHandle::kOk;
-      while (r == WebDataConsumerHandle::kOk) {
-        const void* buffer;
-        size_t size;
-        r = reader_->BeginRead(&buffer, WebDataConsumerHandle::kFlagNone,
-                               &size);
-        if (r == WebDataConsumerHandle::kOk) {
-          buffer_.Append(static_cast<const char*>(buffer), size);
-          reader_->EndRead(size);
-        }
-      }
-      if (r == WebDataConsumerHandle::kShouldWait)
-        return;
-      String error_message =
-          "Unknown error occurred while trying to verify integrity.";
-      finished_ = true;
-      if (r == WebDataConsumerHandle::kDone) {
-        SubresourceIntegrity::ReportInfo report_info;
-        bool check_result = SubresourceIntegrity::CheckSubresourceIntegrity(
-            integrity_metadata_, buffer_.data(), buffer_.size(), url_,
-            report_info);
-        SubresourceIntegrityHelper::DoReport(*loader_->GetExecutionContext(),
-                                             report_info);
-        if (check_result) {
-          updater_->Update(
-              new FormDataBytesConsumer(buffer_.data(), buffer_.size()));
-          loader_->resolver_->Resolve(response_);
-          loader_->resolver_.Clear();
-          // FetchManager::Loader::didFinishLoading() can
-          // be called before didGetReadable() is called
-          // when the data is ready. In that case,
-          // didFinishLoading() doesn't clean up and call
-          // notifyFinished(), so it is necessary to
-          // explicitly finish the loader here.
-          if (loader_->did_finish_loading_)
-            loader_->LoadSucceeded();
-          return;
-        }
-      }
-      updater_->Update(
-          BytesConsumer::CreateErrored(BytesConsumer::Error(error_message)));
-      loader_->PerformNetworkError(error_message);
-    }
-
-    bool IsFinished() const { return finished_; }
-
-    void Trace(blink::Visitor* visitor) {
-      visitor->Trace(updater_);
-      visitor->Trace(response_);
-      visitor->Trace(loader_);
-    }
-
-   private:
-    std::unique_ptr<WebDataConsumerHandle> handle_;
-    Member<SRIBytesConsumer> updater_;
-    // We cannot store a Response because its JS wrapper can be collected.
-    // TODO(yhirano): Fix this.
-    Member<Response> response_;
-    Member<FetchManager::Loader> loader_;
-    String integrity_metadata_;
-    KURL url_;
-    std::unique_ptr<WebDataConsumerHandle::Reader> reader_;
-    Vector<char> buffer_;
-    bool finished_;
-  };
-
- private:
-  Loader(ExecutionContext*,
-         FetchManager*,
-         ScriptPromiseResolver*,
-         FetchRequestData*,
-         bool is_isolated_world);
-
-  void PerformSchemeFetch();
-  void PerformNetworkError(const String& message);
-  void PerformHTTPFetch();
-  void PerformDataFetch();
-  void Failed(const String& message);
-  void NotifyFinished();
-  Document* GetDocument() const;
-  ExecutionContext* GetExecutionContext() { return execution_context_; }
-  void LoadSucceeded();
-
-  Member<FetchManager> fetch_manager_;
-  Member<ScriptPromiseResolver> resolver_;
-  Member<FetchRequestData> request_;
-  Member<ThreadableLoader> loader_;
-  bool failed_;
-  bool finished_;
-  int response_http_status_code_;
-  Member<SRIVerifier> integrity_verifier_;
-  bool did_finish_loading_;
-  bool is_isolated_world_;
-  Vector<KURL> url_list_;
-  Member<ExecutionContext> execution_context_;
-};
-
-FetchManager::Loader::Loader(ExecutionContext* execution_context,
-                             FetchManager* fetch_manager,
-                             ScriptPromiseResolver* resolver,
-                             FetchRequestData* request,
-                             bool is_isolated_world)
-    : fetch_manager_(fetch_manager),
-      resolver_(resolver),
-      request_(request),
-      failed_(false),
-      finished_(false),
-      response_http_status_code_(0),
-      integrity_verifier_(nullptr),
-      did_finish_loading_(false),
-      is_isolated_world_(is_isolated_world),
-      execution_context_(execution_context) {
-  url_list_.push_back(request->Url());
-}
-
-FetchManager::Loader::~Loader() {
-  DCHECK(!loader_);
-}
-
-void FetchManager::Loader::Trace(blink::Visitor* visitor) {
-  visitor->Trace(fetch_manager_);
-  visitor->Trace(resolver_);
-  visitor->Trace(request_);
-  visitor->Trace(loader_);
-  visitor->Trace(integrity_verifier_);
-  visitor->Trace(execution_context_);
-}
-
-void FetchManager::Loader::DidReceiveRedirectTo(const KURL& url) {
-  url_list_.push_back(url);
-}
-
-void FetchManager::Loader::DidReceiveResponse(
-    unsigned long,
-    const ResourceResponse& response,
-    std::unique_ptr<WebDataConsumerHandle> handle) {
-  DCHECK(handle);
-  // TODO(horo): This check could be false when we will use the response url
-  // in service worker responses. (crbug.com/553535)
-  DCHECK(response.Url() == url_list_.back());
-  ScriptState* script_state = resolver_->GetScriptState();
-  ScriptState::Scope scope(script_state);
-
-  if (response.Url().ProtocolIs("blob") && response.HttpStatusCode() == 404) {
-    // "If |blob| is null, return a network error."
-    // https://fetch.spec.whatwg.org/#concept-scheme-fetch
-    PerformNetworkError("Blob not found.");
-    return;
-  }
-
-  if (response.Url().ProtocolIs("blob") && response.HttpStatusCode() == 405) {
-    PerformNetworkError("Only 'GET' method is allowed for blob URLs.");
-    return;
-  }
-
-  response_http_status_code_ = response.HttpStatusCode();
-  FetchRequestData::Tainting tainting = request_->ResponseTainting();
-
-  if (response.Url().ProtocolIsData()) {
-    if (request_->Url() == response.Url()) {
-      // A direct request to data.
-      tainting = FetchRequestData::kBasicTainting;
-    } else {
-      // A redirect to data: scheme occured.
-      // Redirects to data URLs are rejected by the spec because
-      // same-origin data-URL flag is unset, except for no-cors mode.
-      // TODO(hiroshige): currently redirects to data URLs in no-cors
-      // mode is also rejected by Chromium side.
-      switch (request_->Mode()) {
-        case network::mojom::FetchRequestMode::kNoCORS:
-          tainting = FetchRequestData::kOpaqueTainting;
-          break;
-        case network::mojom::FetchRequestMode::kSameOrigin:
-        case network::mojom::FetchRequestMode::kCORS:
-        case network::mojom::FetchRequestMode::kCORSWithForcedPreflight:
-        case network::mojom::FetchRequestMode::kNavigate:
-          PerformNetworkError("Fetch API cannot load " +
-                              request_->Url().GetString() +
-                              ". Redirects to data: URL are allowed only when "
-                              "mode is \"no-cors\".");
-          return;
-      }
-    }
-  } else if (!SecurityOrigin::Create(response.Url())
-                  ->IsSameSchemeHostPort(request_->Origin().get())) {
-    // Recompute the tainting if the request was redirected to a different
-    // origin.
-    switch (request_->Mode()) {
-      case network::mojom::FetchRequestMode::kSameOrigin:
-        NOTREACHED();
-        break;
-      case network::mojom::FetchRequestMode::kNoCORS:
-        tainting = FetchRequestData::kOpaqueTainting;
-        break;
-      case network::mojom::FetchRequestMode::kCORS:
-      case network::mojom::FetchRequestMode::kCORSWithForcedPreflight:
-        tainting = FetchRequestData::kCORSTainting;
-        break;
-      case network::mojom::FetchRequestMode::kNavigate:
-        LOG(FATAL);
-        break;
-    }
-  }
-  if (response.WasFetchedViaServiceWorker()) {
-    switch (response.ResponseTypeViaServiceWorker()) {
-      case network::mojom::FetchResponseType::kBasic:
-      case network::mojom::FetchResponseType::kDefault:
-        tainting = FetchRequestData::kBasicTainting;
-        break;
-      case network::mojom::FetchResponseType::kCORS:
-        tainting = FetchRequestData::kCORSTainting;
-        break;
-      case network::mojom::FetchResponseType::kOpaque:
-        tainting = FetchRequestData::kOpaqueTainting;
-        break;
-      case network::mojom::FetchResponseType::kOpaqueRedirect:
-        DCHECK(
-            NetworkUtils::IsRedirectResponseCode(response_http_status_code_));
-        break;  // The code below creates an opaque-redirect filtered response.
-      case network::mojom::FetchResponseType::kError:
-        LOG(FATAL) << "When ServiceWorker respond to the request from fetch() "
-                      "with an error response, FetchManager::Loader::didFail() "
-                      "must be called instead.";
-        break;
-    }
-  }
-
-  FetchResponseData* response_data = nullptr;
-  SRIBytesConsumer* sri_consumer = nullptr;
-  if (request_->Integrity().IsEmpty()) {
-    response_data = FetchResponseData::CreateWithBuffer(new BodyStreamBuffer(
-        script_state,
-        new BytesConsumerForDataConsumerHandle(
-            ExecutionContext::From(script_state), std::move(handle))));
-  } else {
-    sri_consumer = new SRIBytesConsumer();
-    response_data = FetchResponseData::CreateWithBuffer(
-        new BodyStreamBuffer(script_state, sri_consumer));
-  }
-  response_data->SetStatus(response.HttpStatusCode());
-  response_data->SetStatusMessage(response.HttpStatusText());
-  for (auto& it : response.HttpHeaderFields())
-    response_data->HeaderList()->Append(it.key, it.value);
-  if (response.UrlListViaServiceWorker().IsEmpty()) {
-    // Note: |urlListViaServiceWorker| is empty, unless the response came from a
-    // service worker, in which case it will only be empty if it was created
-    // through new Response().
-    response_data->SetURLList(url_list_);
-  } else {
-    DCHECK(response.WasFetchedViaServiceWorker());
-    response_data->SetURLList(response.UrlListViaServiceWorker());
-  }
-  response_data->SetMIMEType(response.MimeType());
-  response_data->SetResponseTime(response.ResponseTime());
-
-  FetchResponseData* tainted_response = nullptr;
-
-  DCHECK(!(NetworkUtils::IsRedirectResponseCode(response_http_status_code_) &&
-           response_data->HeaderList()->Has(HTTPNames::Location) &&
-           request_->Redirect() != WebURLRequest::kFetchRedirectModeManual));
-
-  if (NetworkUtils::IsRedirectResponseCode(response_http_status_code_) &&
-      request_->Redirect() == WebURLRequest::kFetchRedirectModeManual) {
-    tainted_response = response_data->CreateOpaqueRedirectFilteredResponse();
-  } else {
-    switch (tainting) {
-      case FetchRequestData::kBasicTainting:
-        tainted_response = response_data->CreateBasicFilteredResponse();
-        break;
-      case FetchRequestData::kCORSTainting: {
-        WebHTTPHeaderSet header_names =
-            WebCORS::ExtractCorsExposedHeaderNamesList(
-                request_->Credentials(), WrappedResourceResponse(response));
-        tainted_response =
-            response_data->CreateCORSFilteredResponse(header_names);
-        break;
-      }
-      case FetchRequestData::kOpaqueTainting:
-        tainted_response = response_data->CreateOpaqueFilteredResponse();
-        break;
-    }
-  }
-
-  Response* r =
-      Response::Create(resolver_->GetExecutionContext(), tainted_response);
-  if (response.Url().ProtocolIsData()) {
-    // An "Access-Control-Allow-Origin" header is added for data: URLs
-    // but no headers except for "Content-Type" should exist,
-    // according to the spec:
-    // https://fetch.spec.whatwg.org/#concept-scheme-fetch
-    // "... return a response whose header list consist of a single header
-    //  whose name is `Content-Type` and value is the MIME type and
-    //  parameters returned from obtaining a resource"
-    r->headers()->HeaderList()->Remove(HTTPNames::Access_Control_Allow_Origin);
-  }
-  r->headers()->SetGuard(Headers::kImmutableGuard);
-
-  if (request_->Integrity().IsEmpty()) {
-    resolver_->Resolve(r);
-    resolver_.Clear();
-  } else {
-    DCHECK(!integrity_verifier_);
-    integrity_verifier_ =
-        new SRIVerifier(std::move(handle), sri_consumer, r, this,
-                        request_->Integrity(), response.Url());
-  }
-}
-
-void FetchManager::Loader::DidFinishLoading(unsigned long, double) {
-  did_finish_loading_ = true;
-  // If there is an integrity verifier, and it has not already finished, it
-  // will take care of finishing the load or performing a network error when
-  // verification is complete.
-  if (integrity_verifier_ && !integrity_verifier_->IsFinished())
-    return;
-
-  LoadSucceeded();
-}
-
-void FetchManager::Loader::DidFail(const ResourceError& error) {
-  Failed(String());
-}
-
-void FetchManager::Loader::DidFailRedirectCheck() {
-  Failed("Fetch API cannot load " + request_->Url().GetString() +
-         ". Redirect failed.");
-}
-
-Document* FetchManager::Loader::GetDocument() const {
-  if (execution_context_->IsDocument()) {
-    return ToDocument(execution_context_);
-  }
-  return nullptr;
-}
-
-void FetchManager::Loader::LoadSucceeded() {
-  DCHECK(!failed_);
-
-  finished_ = true;
-
-  if (GetDocument() && GetDocument()->GetFrame() &&
-      GetDocument()->GetFrame()->GetPage() &&
-      FetchUtils::IsOkStatus(response_http_status_code_)) {
-    GetDocument()->GetFrame()->GetPage()->GetChromeClient().AjaxSucceeded(
-        GetDocument()->GetFrame());
-  }
-  probe::didFinishFetch(execution_context_, this, request_->Method(),
-                        request_->Url().GetString());
-  NotifyFinished();
-}
-
-void FetchManager::Loader::Start() {
-  // "1. If |request|'s url contains a Known HSTS Host, modify it per the
-  // requirements of the 'URI [sic] Loading and Port Mapping' chapter of HTTP
-  // Strict Transport Security."
-  // FIXME: Implement this.
-
-  // "2. If |request|'s referrer is not none, set |request|'s referrer to the
-  // result of invoking determine |request|'s referrer."
-  // We set the referrer using workerGlobalScope's URL in
-  // WorkerThreadableLoader.
-
-  // "3. If |request|'s synchronous flag is unset and fetch is not invoked
-  // recursively, run the remaining steps asynchronously."
-  // We don't support synchronous flag.
-
-  // "4. Let response be the value corresponding to the first matching
-  // statement:"
-
-  // "- should fetching |request| be blocked as mixed content returns blocked"
-  // We do mixed content checking in ResourceFetcher.
-
-  // "- should fetching |request| be blocked as content security returns
-  //    blocked"
-  if (!ContentSecurityPolicy::ShouldBypassMainWorld(execution_context_) &&
-      !execution_context_->GetContentSecurityPolicy()->AllowConnectToSource(
-          request_->Url())) {
-    // "A network error."
-    PerformNetworkError(
-        "Refused to connect to '" + request_->Url().ElidedString() +
-        "' because it violates the document's Content Security Policy.");
-    return;
-  }
-
-  // "- |request|'s url's origin is |request|'s origin and the |CORS flag| is
-  //    unset"
-  // "- |request|'s url's scheme is 'data' and |request|'s same-origin data
-  //    URL flag is set"
-  // "- |request|'s url's scheme is 'about'"
-  // Note we don't support to call this method with |CORS flag|
-  // "- |request|'s mode is |navigate|".
-  if ((SecurityOrigin::Create(request_->Url())
-           ->IsSameSchemeHostPortAndSuborigin(request_->Origin().get())) ||
-      (request_->Url().ProtocolIsData() && request_->SameOriginDataURLFlag()) ||
-      (request_->Mode() == network::mojom::FetchRequestMode::kNavigate)) {
-    // "The result of performing a scheme fetch using request."
-    PerformSchemeFetch();
-    return;
-  }
-
-  // "- |request|'s mode is |same-origin|"
-  if (request_->Mode() == network::mojom::FetchRequestMode::kSameOrigin) {
-    // "A network error."
-    PerformNetworkError("Fetch API cannot load " + request_->Url().GetString() +
-                        ". Request mode is \"same-origin\" but the URL\'s "
-                        "origin is not same as the request origin " +
-                        request_->Origin()->ToString() + ".");
-    return;
-  }
-
-  // "- |request|'s mode is |no CORS|"
-  if (request_->Mode() == network::mojom::FetchRequestMode::kNoCORS) {
-    // "Set |request|'s response tainting to |opaque|."
-    request_->SetResponseTainting(FetchRequestData::kOpaqueTainting);
-    // "The result of performing a scheme fetch using |request|."
-    PerformSchemeFetch();
-    return;
-  }
-
-  // "- |request|'s url's scheme is not one of 'http' and 'https'"
-  // This may include other HTTP-like schemes if the embedder has added them
-  // to SchemeRegistry::registerURLSchemeAsSupportingFetchAPI.
-  if (!SchemeRegistry::ShouldTreatURLSchemeAsSupportingFetchAPI(
-          request_->Url().Protocol())) {
-    // "A network error."
-    PerformNetworkError(
-        "Fetch API cannot load " + request_->Url().GetString() +
-        ". URL scheme must be \"http\" or \"https\" for CORS request.");
-    return;
-  }
-
-  // "Set |request|'s response tainting to |CORS|."
-  request_->SetResponseTainting(FetchRequestData::kCORSTainting);
-
-  // "The result of performing an HTTP fetch using |request| with the
-  // |CORS flag| set."
-  PerformHTTPFetch();
-}
-
-void FetchManager::Loader::Dispose() {
-  probe::detachClientRequest(execution_context_, this);
-  // Prevent notification
-  fetch_manager_ = nullptr;
-  if (loader_) {
-    if (request_->Keepalive())
-      loader_->Detach();
-    else
-      loader_->Cancel();
-    loader_ = nullptr;
-  }
-  if (integrity_verifier_)
-    integrity_verifier_->Cancel();
-  execution_context_ = nullptr;
-}
-
-void FetchManager::Loader::PerformSchemeFetch() {
-  // "To perform a scheme fetch using |request|, switch on |request|'s url's
-  // scheme, and run the associated steps:"
-  if (SchemeRegistry::ShouldTreatURLSchemeAsSupportingFetchAPI(
-          request_->Url().Protocol()) ||
-      request_->Url().ProtocolIs("blob")) {
-    // "Return the result of performing an HTTP fetch using |request|."
-    PerformHTTPFetch();
-  } else if (request_->Url().ProtocolIsData()) {
-    PerformDataFetch();
-  } else {
-    // FIXME: implement other protocols.
-    PerformNetworkError("Fetch API cannot load " + request_->Url().GetString() +
-                        ". URL scheme \"" + request_->Url().Protocol() +
-                        "\" is not supported.");
-  }
-}
-
-void FetchManager::Loader::PerformNetworkError(const String& message) {
-  Failed(message);
-}
-
-void FetchManager::Loader::PerformHTTPFetch() {
-  // CORS preflight fetch procedure is implemented inside
-  // DocumentThreadableLoader.
-
-  // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s
-  //  body is a tee of |request|'s body."
-  // We use ResourceRequest class for HTTPRequest.
-  // FIXME: Support body.
-  ResourceRequest request(request_->Url());
-  request.SetRequestContext(request_->Context());
-  request.SetHTTPMethod(request_->Method());
-
-  switch (request_->Mode()) {
-    case network::mojom::FetchRequestMode::kSameOrigin:
-    case network::mojom::FetchRequestMode::kNoCORS:
-    case network::mojom::FetchRequestMode::kCORS:
-    case network::mojom::FetchRequestMode::kCORSWithForcedPreflight:
-      request.SetFetchRequestMode(request_->Mode());
-      break;
-    case network::mojom::FetchRequestMode::kNavigate:
-      // Using kSameOrigin here to reduce the security risk.
-      // "navigate" request is only available in ServiceWorker.
-      request.SetFetchRequestMode(
-          network::mojom::FetchRequestMode::kSameOrigin);
-      break;
-  }
-
-  request.SetFetchCredentialsMode(request_->Credentials());
-  for (const auto& header : request_->HeaderList()->List()) {
-    // Since |request_|'s headers are populated with either of the "request"
-    // guard or "request-no-cors" guard, we can assume that none of the headers
-    // have a name listed in the forbidden header names.
-    DCHECK(!FetchUtils::IsForbiddenHeaderName(header.first));
-
-    request.AddHTTPHeaderField(AtomicString(header.first),
-                               AtomicString(header.second));
-  }
-
-  if (request_->Method() != HTTPNames::GET &&
-      request_->Method() != HTTPNames::HEAD) {
-    if (request_->Buffer())
-      request.SetHTTPBody(request_->Buffer()->DrainAsFormData());
-  }
-  request.SetCacheMode(request_->CacheMode());
-  request.SetFetchRedirectMode(request_->Redirect());
-  request.SetUseStreamOnResponse(true);
-  request.SetExternalRequestStateFromRequestorAddressSpace(
-      execution_context_->GetSecurityContext().AddressSpace());
-
-  // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer|
-  // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8
-  // encoded, otherwise, to HTTPRequest's header list.
-  //
-  // The following code also invokes "determine request's referrer" which is
-  // written in "Main fetch" operation.
-  const ReferrerPolicy referrer_policy =
-      request_->GetReferrerPolicy() == kReferrerPolicyDefault
-          ? execution_context_->GetReferrerPolicy()
-          : request_->GetReferrerPolicy();
-  const String referrer_string =
-      request_->ReferrerString() == FetchRequestData::ClientReferrerString()
-          ? execution_context_->OutgoingReferrer()
-          : request_->ReferrerString();
-  // Note that generateReferrer generates |no-referrer| from |no-referrer|
-  // referrer string (i.e. String()).
-  request.SetHTTPReferrer(SecurityPolicy::GenerateReferrer(
-      referrer_policy, request_->Url(), referrer_string));
-  request.SetServiceWorkerMode(is_isolated_world_
-                                   ? WebURLRequest::ServiceWorkerMode::kNone
-                                   : WebURLRequest::ServiceWorkerMode::kAll);
-
-  if (request_->Keepalive()) {
-    if (!WebCORS::IsCORSSafelistedMethod(request.HttpMethod()) ||
-        !WebCORS::ContainsOnlyCORSSafelistedOrForbiddenHeaders(
-            request.HttpHeaderFields())) {
-      PerformNetworkError(
-          "Preflight request for request with keepalive "
-          "specified is currently not supported");
-      return;
-    }
-    request.SetKeepalive(true);
-  }
-  // "3. Append `Host`, ..."
-  // FIXME: Implement this when the spec is fixed.
-
-  // "4.If |HTTPRequest|'s force Origin header flag is set, append `Origin`/
-  // |HTTPRequest|'s origin, serialized and utf-8 encoded, to |HTTPRequest|'s
-  // header list."
-  // We set Origin header in updateRequestForAccessControl() called from
-  // DocumentThreadableLoader::makeCrossOriginAccessRequest
-
-  // "5. Let |credentials flag| be set if either |HTTPRequest|'s credentials
-  // mode is |include|, or |HTTPRequest|'s credentials mode is |same-origin|
-  // and the |CORS flag| is unset, and unset otherwise."
-
-  ResourceLoaderOptions resource_loader_options;
-  resource_loader_options.data_buffering_policy = kDoNotBufferData;
-  resource_loader_options.security_origin = request_->Origin().get();
-
-  ThreadableLoaderOptions threadable_loader_options;
-
-  probe::willStartFetch(execution_context_, this);
-  loader_ = ThreadableLoader::Create(*execution_context_, this,
-                                     threadable_loader_options,
-                                     resource_loader_options);
-  loader_->Start(request);
-}
-
-// performDataFetch() is almost the same as performHTTPFetch(), except for:
-// - We set AllowCrossOriginRequests to allow requests to data: URLs in
-//   'same-origin' mode.
-// - We reject non-GET method.
-void FetchManager::Loader::PerformDataFetch() {
-  DCHECK(request_->Url().ProtocolIsData());
-
-  ResourceRequest request(request_->Url());
-  request.SetRequestContext(request_->Context());
-  request.SetUseStreamOnResponse(true);
-  request.SetHTTPMethod(request_->Method());
-  request.SetFetchCredentialsMode(network::mojom::FetchCredentialsMode::kOmit);
-  request.SetFetchRedirectMode(WebURLRequest::kFetchRedirectModeError);
-  // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace',
-  // as 'data:' can never be external.
-
-  ResourceLoaderOptions resource_loader_options;
-  resource_loader_options.data_buffering_policy = kDoNotBufferData;
-  resource_loader_options.security_origin = request_->Origin().get();
-
-  ThreadableLoaderOptions threadable_loader_options;
-
-  probe::willStartFetch(execution_context_, this);
-  loader_ = ThreadableLoader::Create(*execution_context_, this,
-                                     threadable_loader_options,
-                                     resource_loader_options);
-  loader_->Start(request);
-}
-
-void FetchManager::Loader::Failed(const String& message) {
-  if (failed_ || finished_)
-    return;
-  failed_ = true;
-  if (execution_context_->IsContextDestroyed())
-    return;
-  if (!message.IsEmpty()) {
-    execution_context_->AddConsoleMessage(
-        ConsoleMessage::Create(kJSMessageSource, kErrorMessageLevel, message));
-  }
-  if (resolver_) {
-    ScriptState* state = resolver_->GetScriptState();
-    ScriptState::Scope scope(state);
-    resolver_->Reject(V8ThrowException::CreateTypeError(state->GetIsolate(),
-                                                        "Failed to fetch"));
-  }
-  probe::didFailFetch(execution_context_, this);
-  NotifyFinished();
-}
-
-void FetchManager::Loader::NotifyFinished() {
-  if (fetch_manager_)
-    fetch_manager_->OnLoaderFinished(this);
-}
-
-FetchManager* FetchManager::Create(ExecutionContext* execution_context) {
-  return new FetchManager(execution_context);
-}
-
-FetchManager::FetchManager(ExecutionContext* execution_context)
-    : ContextLifecycleObserver(execution_context) {}
-
-ScriptPromise FetchManager::Fetch(ScriptState* script_state,
-                                  FetchRequestData* request) {
-  ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
-  ScriptPromise promise = resolver->Promise();
-
-  request->SetContext(WebURLRequest::kRequestContextFetch);
-
-  Loader* loader =
-      Loader::Create(GetExecutionContext(), this, resolver, request,
-                     script_state->World().IsIsolatedWorld());
-  loaders_.insert(loader);
-  loader->Start();
-  return promise;
-}
-
-void FetchManager::ContextDestroyed(ExecutionContext*) {
-  for (auto& loader : loaders_)
-    loader->Dispose();
-}
-
-void FetchManager::OnLoaderFinished(Loader* loader) {
-  loaders_.erase(loader);
-  loader->Dispose();
-}
-
-void FetchManager::Trace(blink::Visitor* visitor) {
-  visitor->Trace(loaders_);
-  ContextLifecycleObserver::Trace(visitor);
-}
-
-}  // namespace blink
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.h b/third_party/WebKit/Source/core/layout/LayoutObject.h
index 0a86c6a..de7bc2f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.h
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.h
@@ -882,8 +882,6 @@
 
   bool HasShapeOutside() const { return Style() && Style()->ShapeOutside(); }
 
-  inline bool PreservesNewline() const;
-
   // The pseudo element style can be cached or uncached.  Use the cached method
   // if the pseudo element doesn't respect any pseudo classes (and therefore
   // has no concept of changing state).
@@ -2718,13 +2716,6 @@
     MarkContainerChainForLayout();
 }
 
-inline bool LayoutObject::PreservesNewline() const {
-  if (IsSVGInlineText())
-    return false;
-
-  return Style()->PreserveNewline();
-}
-
 inline void LayoutObject::SetHasBoxDecorationBackground(bool b) {
   if (b == bitfields_.HasBoxDecorationBackground())
     return;
diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h b/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h
index e702b2f..64e64da 100644
--- a/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h
+++ b/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h
@@ -123,9 +123,12 @@
 
   Document& GetDocument() const { return layout_object_->GetDocument(); }
 
-  // TODO(dgrogan): This is the only caller: move the logic from LayoutObject
-  // to here.
-  bool PreservesNewline() const { return layout_object_->PreservesNewline(); }
+  bool PreservesNewline() const {
+    if (IsSVGInlineText())
+      return false;
+
+    return Style()->PreserveNewline();
+  }
 
   unsigned length() const { return layout_object_->length(); }
 
diff --git a/third_party/WebKit/Source/core/workers/RequestCredentials.idl b/third_party/WebKit/Source/core/workers/RequestCredentials.idl
new file mode 100644
index 0000000..1212237
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/RequestCredentials.idl
@@ -0,0 +1,10 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// https://fetch.spec.whatwg.org/#requestcredentials
+// Copied from modules/fetch/Request.idl because it's not accessible from core/
+// directory.
+// TODO(nhiroki): Consider how to reuse the existing enum (e.g.,
+// https://crbug.com/794837)
+enum RequestCredentials { "omit", "same-origin", "include" };
diff --git a/third_party/WebKit/Source/modules/BUILD.gn b/third_party/WebKit/Source/modules/BUILD.gn
index 9ee1f43..4ef12f6 100644
--- a/third_party/WebKit/Source/modules/BUILD.gn
+++ b/third_party/WebKit/Source/modules/BUILD.gn
@@ -263,6 +263,9 @@
     "csspaint/PaintWorkletTest.cpp",
     "document_metadata/CopylessPasteExtractorTest.cpp",
     "eventsource/EventSourceParserTest.cpp",
+    "fetch/FetchResponseDataTest.cpp",
+    "fetch/RequestTest.cpp",
+    "fetch/ResponseTest.cpp",
     "filesystem/DOMFileSystemBaseTest.cpp",
     "indexeddb/IDBKeyPathTest.cpp",
     "indexeddb/IDBRequestTest.cpp",
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFailEvent.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFailEvent.cpp
index d0b335c6..1cdacc3 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFailEvent.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFailEvent.cpp
@@ -4,11 +4,11 @@
 
 #include "modules/background_fetch/BackgroundFetchFailEvent.h"
 
-#include "core/fetch/Request.h"
-#include "core/fetch/Response.h"
 #include "modules/background_fetch/BackgroundFetchFailEventInit.h"
 #include "modules/background_fetch/BackgroundFetchSettledFetch.h"
 #include "modules/event_modules_names.h"
+#include "modules/fetch/Request.h"
+#include "modules/fetch/Response.h"
 #include "public/platform/modules/background_fetch/WebBackgroundFetchSettledFetch.h"
 
 namespace blink {
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFetch.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFetch.cpp
index f14ef33..65a2f9a 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFetch.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchFetch.cpp
@@ -4,7 +4,7 @@
 
 #include "modules/background_fetch/BackgroundFetchFetch.h"
 
-#include "core/fetch/Request.h"
+#include "modules/fetch/Request.h"
 
 namespace blink {
 
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp
index ec3a8308..bd4f551 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManager.cpp
@@ -5,11 +5,10 @@
 #include "modules/background_fetch/BackgroundFetchManager.h"
 
 #include "bindings/core/v8/ScriptPromiseResolver.h"
-#include "bindings/core/v8/request_or_usv_string.h"
+#include "bindings/modules/v8/request_or_usv_string.h"
 #include "bindings/modules/v8/request_or_usv_string_or_request_or_usv_string_sequence.h"
 #include "core/dom/DOMException.h"
 #include "core/dom/ExceptionCode.h"
-#include "core/fetch/Request.h"
 #include "core/frame/Deprecation.h"
 #include "core/frame/UseCounter.h"
 #include "core/frame/csp/ContentSecurityPolicy.h"
@@ -17,6 +16,7 @@
 #include "modules/background_fetch/BackgroundFetchBridge.h"
 #include "modules/background_fetch/BackgroundFetchOptions.h"
 #include "modules/background_fetch/BackgroundFetchRegistration.h"
+#include "modules/fetch/Request.h"
 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
 #include "platform/bindings/ScriptState.h"
 #include "platform/bindings/V8ThrowException.h"
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManagerTest.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManagerTest.cpp
index 7bce8987..e937094 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManagerTest.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchManagerTest.cpp
@@ -8,10 +8,10 @@
 #include "bindings/core/v8/ExceptionState.h"
 #include "bindings/core/v8/V8BindingForCore.h"
 #include "bindings/core/v8/V8BindingForTesting.h"
-#include "bindings/core/v8/request_or_usv_string.h"
+#include "bindings/modules/v8/request_or_usv_string.h"
 #include "bindings/modules/v8/request_or_usv_string_or_request_or_usv_string_sequence.h"
 #include "core/dom/ExceptionCode.h"
-#include "core/fetch/Request.h"
+#include "modules/fetch/Request.h"
 #include "platform/bindings/ScriptState.h"
 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
 #include "testing/gtest/include/gtest/gtest.h"
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchSettledFetch.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchSettledFetch.cpp
index c4a93fa..de258cd 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchSettledFetch.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchSettledFetch.cpp
@@ -4,7 +4,7 @@
 
 #include "modules/background_fetch/BackgroundFetchSettledFetch.h"
 
-#include "core/fetch/Response.h"
+#include "modules/fetch/Response.h"
 
 namespace blink {
 
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.cpp
index f1896bc..466f0fc 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchedEvent.cpp
@@ -6,12 +6,12 @@
 
 #include "bindings/core/v8/ScriptPromiseResolver.h"
 #include "core/dom/DOMException.h"
-#include "core/fetch/Request.h"
-#include "core/fetch/Response.h"
 #include "modules/background_fetch/BackgroundFetchBridge.h"
 #include "modules/background_fetch/BackgroundFetchSettledFetch.h"
 #include "modules/background_fetch/BackgroundFetchedEventInit.h"
 #include "modules/event_modules_names.h"
+#include "modules/fetch/Request.h"
+#include "modules/fetch/Response.h"
 #include "platform/bindings/ScriptState.h"
 #include "public/platform/modules/background_fetch/WebBackgroundFetchSettledFetch.h"
 
diff --git a/third_party/WebKit/Source/modules/cachestorage/Cache.cpp b/third_party/WebKit/Source/modules/cachestorage/Cache.cpp
index 672c067..5f1c7ceb 100644
--- a/third_party/WebKit/Source/modules/cachestorage/Cache.cpp
+++ b/third_party/WebKit/Source/modules/cachestorage/Cache.cpp
@@ -12,18 +12,18 @@
 #include "bindings/core/v8/NativeValueTraitsImpl.h"
 #include "bindings/core/v8/ScriptPromiseResolver.h"
 #include "bindings/core/v8/V8BindingForCore.h"
-#include "bindings/core/v8/V8Response.h"
 #include "bindings/core/v8/V8ScriptRunner.h"
+#include "bindings/modules/v8/V8Response.h"
 #include "core/dom/DOMException.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/FetchDataLoader.h"
-#include "core/fetch/Request.h"
-#include "core/fetch/Response.h"
 #include "core/html/parser/TextResourceDecoder.h"
 #include "core/inspector/ConsoleMessage.h"
 #include "modules/cachestorage/CacheStorageError.h"
 #include "modules/fetch/GlobalFetch.h"
+#include "modules/fetch/Request.h"
+#include "modules/fetch/Response.h"
 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
 #include "platform/Histogram.h"
 #include "platform/bindings/ScriptState.h"
diff --git a/third_party/WebKit/Source/modules/cachestorage/CacheStorage.cpp b/third_party/WebKit/Source/modules/cachestorage/CacheStorage.cpp
index 4af3b86..bfd496b 100644
--- a/third_party/WebKit/Source/modules/cachestorage/CacheStorage.cpp
+++ b/third_party/WebKit/Source/modules/cachestorage/CacheStorage.cpp
@@ -12,10 +12,10 @@
 #include "core/dom/DOMException.h"
 #include "core/dom/ExceptionCode.h"
 #include "core/dom/ExecutionContext.h"
-#include "core/fetch/Request.h"
-#include "core/fetch/Response.h"
 #include "core/inspector/ConsoleMessage.h"
 #include "modules/cachestorage/CacheStorageError.h"
+#include "modules/fetch/Request.h"
+#include "modules/fetch/Response.h"
 #include "platform/bindings/ScriptState.h"
 #include "platform/network/http_names.h"
 #include "public/platform/modules/cache_storage/cache_storage.mojom-blink.h"
diff --git a/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp b/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp
index e3b5ef36..74d9264 100644
--- a/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp
+++ b/third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp
@@ -17,17 +17,17 @@
 #include "bindings/core/v8/ScriptPromiseResolver.h"
 #include "bindings/core/v8/ScriptValue.h"
 #include "bindings/core/v8/V8BindingForCore.h"
-#include "bindings/core/v8/V8Request.h"
-#include "bindings/core/v8/V8Response.h"
+#include "bindings/modules/v8/V8Request.h"
+#include "bindings/modules/v8/V8Response.h"
 #include "core/dom/Document.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/FormDataBytesConsumer.h"
-#include "core/fetch/Request.h"
-#include "core/fetch/Response.h"
 #include "core/frame/Frame.h"
 #include "core/testing/DummyPageHolder.h"
 #include "modules/fetch/GlobalFetch.h"
+#include "modules/fetch/Request.h"
+#include "modules/fetch/Response.h"
 #include "modules/fetch/ResponseInit.h"
 #include "public/platform/WebURLResponse.h"
 #include "public/platform/modules/cache_storage/cache_storage.mojom-blink.h"
diff --git a/third_party/WebKit/Source/modules/fetch/BUILD.gn b/third_party/WebKit/Source/modules/fetch/BUILD.gn
index 561003b..ebf5680 100644
--- a/third_party/WebKit/Source/modules/fetch/BUILD.gn
+++ b/third_party/WebKit/Source/modules/fetch/BUILD.gn
@@ -6,8 +6,20 @@
 
 blink_modules_sources("fetch") {
   sources = [
+    "FetchManager.cpp",
+    "FetchManager.h",
+    "FetchRequestData.cpp",
+    "FetchRequestData.h",
+    "FetchResponseData.cpp",
+    "FetchResponseData.h",
     "GlobalFetch.cpp",
     "GlobalFetch.h",
+    "Request.cpp",
+    "Request.h",
+    "RequestInit.cpp",
+    "RequestInit.h",
+    "Response.cpp",
+    "Response.h",
   ]
 
   public_deps = [
diff --git a/third_party/WebKit/Source/modules/fetch/FetchManager.cpp b/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
index 672985c..323d1e2 100644
--- a/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchManager.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/FetchManager.h"
+#include "modules/fetch/FetchManager.h"
 
 #include <memory>
 #include "bindings/core/v8/ExceptionState.h"
@@ -12,10 +12,7 @@
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/BytesConsumer.h"
 #include "core/fetch/BytesConsumerForDataConsumerHandle.h"
-#include "core/fetch/FetchRequestData.h"
 #include "core/fetch/FormDataBytesConsumer.h"
-#include "core/fetch/Response.h"
-#include "core/fetch/ResponseInit.h"
 #include "core/fileapi/Blob.h"
 #include "core/frame/Frame.h"
 #include "core/frame/csp/ContentSecurityPolicy.h"
@@ -27,6 +24,9 @@
 #include "core/page/Page.h"
 #include "core/probe/CoreProbes.h"
 #include "core/typed_arrays/DOMArrayBuffer.h"
+#include "modules/fetch/FetchRequestData.h"
+#include "modules/fetch/Response.h"
+#include "modules/fetch/ResponseInit.h"
 #include "platform/bindings/ScriptState.h"
 #include "platform/bindings/V8ThrowException.h"
 #include "platform/exported/WrappedResourceResponse.h"
diff --git a/third_party/WebKit/Source/core/fetch/FetchManager.h b/third_party/WebKit/Source/modules/fetch/FetchManager.h
similarity index 83%
rename from third_party/WebKit/Source/core/fetch/FetchManager.h
rename to third_party/WebKit/Source/modules/fetch/FetchManager.h
index 1cad19a3..f016142 100644
--- a/third_party/WebKit/Source/core/fetch/FetchManager.h
+++ b/third_party/WebKit/Source/modules/fetch/FetchManager.h
@@ -6,7 +6,6 @@
 #define FetchManager_h
 
 #include "bindings/core/v8/ScriptPromise.h"
-#include "core/CoreExport.h"
 #include "core/dom/ContextLifecycleObserver.h"
 #include "platform/heap/Handle.h"
 
@@ -16,8 +15,8 @@
 class FetchRequestData;
 class ScriptState;
 
-class CORE_EXPORT FetchManager final : public GarbageCollected<FetchManager>,
-                                       public ContextLifecycleObserver {
+class FetchManager final : public GarbageCollected<FetchManager>,
+                           public ContextLifecycleObserver {
   USING_GARBAGE_COLLECTED_MIXIN(FetchManager);
 
  public:
diff --git a/third_party/WebKit/Source/core/fetch/FetchRequestData.cpp b/third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp
similarity index 98%
rename from third_party/WebKit/Source/core/fetch/FetchRequestData.cpp
rename to third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp
index 05d6e8a..6138cd1 100644
--- a/third_party/WebKit/Source/core/fetch/FetchRequestData.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/FetchRequestData.h"
+#include "modules/fetch/FetchRequestData.h"
 
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BlobBytesConsumer.h"
diff --git a/third_party/WebKit/Source/core/fetch/FetchRequestData.h b/third_party/WebKit/Source/modules/fetch/FetchRequestData.h
similarity index 100%
rename from third_party/WebKit/Source/core/fetch/FetchRequestData.h
rename to third_party/WebKit/Source/modules/fetch/FetchRequestData.h
diff --git a/third_party/WebKit/Source/core/fetch/FetchResponseData.cpp b/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
similarity index 99%
rename from third_party/WebKit/Source/core/fetch/FetchResponseData.cpp
rename to third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
index 81faa0d2..1a644a19 100644
--- a/third_party/WebKit/Source/core/fetch/FetchResponseData.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/FetchResponseData.h"
+#include "modules/fetch/FetchResponseData.h"
 
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/FetchHeaderList.h"
diff --git a/third_party/WebKit/Source/core/fetch/FetchResponseData.h b/third_party/WebKit/Source/modules/fetch/FetchResponseData.h
similarity index 97%
rename from third_party/WebKit/Source/core/fetch/FetchResponseData.h
rename to third_party/WebKit/Source/modules/fetch/FetchResponseData.h
index 5fc34fb..14260bc5 100644
--- a/third_party/WebKit/Source/core/fetch/FetchResponseData.h
+++ b/third_party/WebKit/Source/modules/fetch/FetchResponseData.h
@@ -9,7 +9,7 @@
 
 #include "base/macros.h"
 #include "base/memory/scoped_refptr.h"
-#include "core/CoreExport.h"
+#include "modules/ModulesExport.h"
 #include "platform/heap/Handle.h"
 #include "platform/weborigin/KURL.h"
 #include "platform/wtf/Time.h"
@@ -27,7 +27,7 @@
 class ScriptState;
 class WebServiceWorkerResponse;
 
-class CORE_EXPORT FetchResponseData final
+class MODULES_EXPORT FetchResponseData final
     : public GarbageCollectedFinalized<FetchResponseData> {
  public:
   // "A response can have an associated termination reason which is one of
diff --git a/third_party/WebKit/Source/core/fetch/FetchResponseDataTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
similarity index 99%
rename from third_party/WebKit/Source/core/fetch/FetchResponseDataTest.cpp
rename to third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
index dfbc85c2..e17c59f 100644
--- a/third_party/WebKit/Source/core/fetch/FetchResponseDataTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FetchResponseDataTest.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/FetchResponseData.h"
+#include "modules/fetch/FetchResponseData.h"
 
 #include "core/fetch/FetchHeaderList.h"
 #include "core/typed_arrays/DOMArrayBuffer.h"
diff --git a/third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp b/third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp
index 9dab718..4fffb2b 100644
--- a/third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp
+++ b/third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp
@@ -4,12 +4,12 @@
 
 #include "modules/fetch/GlobalFetch.h"
 
-#include "core/fetch/FetchManager.h"
-#include "core/fetch/Request.h"
 #include "core/frame/LocalDOMWindow.h"
 #include "core/frame/UseCounter.h"
 #include "core/probe/CoreProbes.h"
 #include "core/workers/WorkerGlobalScope.h"
+#include "modules/fetch/FetchManager.h"
+#include "modules/fetch/Request.h"
 #include "platform/Supplementable.h"
 #include "platform/heap/Handle.h"
 
diff --git a/third_party/WebKit/Source/modules/fetch/GlobalFetch.h b/third_party/WebKit/Source/modules/fetch/GlobalFetch.h
index 277fd49..2cdb7af 100644
--- a/third_party/WebKit/Source/modules/fetch/GlobalFetch.h
+++ b/third_party/WebKit/Source/modules/fetch/GlobalFetch.h
@@ -6,8 +6,8 @@
 #define GlobalFetch_h
 
 #include "bindings/core/v8/ScriptPromise.h"
-#include "core/fetch/Request.h"
 #include "modules/ModulesExport.h"
+#include "modules/fetch/Request.h"
 
 namespace blink {
 
diff --git a/third_party/WebKit/Source/core/fetch/Request.cpp b/third_party/WebKit/Source/modules/fetch/Request.cpp
similarity index 99%
rename from third_party/WebKit/Source/core/fetch/Request.cpp
rename to third_party/WebKit/Source/modules/fetch/Request.cpp
index 6d3ca8d..7e9b284 100644
--- a/third_party/WebKit/Source/core/fetch/Request.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Request.cpp
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/Request.h"
+#include "modules/fetch/Request.h"
 
 #include "bindings/core/v8/Dictionary.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BodyStreamBuffer.h"
-#include "core/fetch/FetchManager.h"
-#include "core/fetch/RequestInit.h"
 #include "core/loader/ThreadableLoader.h"
+#include "modules/fetch/FetchManager.h"
+#include "modules/fetch/RequestInit.h"
 #include "platform/bindings/V8PrivateProperty.h"
 #include "platform/loader/fetch/FetchUtils.h"
 #include "platform/loader/fetch/ResourceLoaderOptions.h"
diff --git a/third_party/WebKit/Source/core/fetch/Request.h b/third_party/WebKit/Source/modules/fetch/Request.h
similarity index 94%
rename from third_party/WebKit/Source/core/fetch/Request.h
rename to third_party/WebKit/Source/modules/fetch/Request.h
index 75b607c4..c03c5f3 100644
--- a/third_party/WebKit/Source/core/fetch/Request.h
+++ b/third_party/WebKit/Source/modules/fetch/Request.h
@@ -6,11 +6,11 @@
 #define Request_h
 
 #include "bindings/core/v8/Dictionary.h"
-#include "bindings/core/v8/request_or_usv_string.h"
-#include "core/CoreExport.h"
+#include "bindings/modules/v8/request_or_usv_string.h"
 #include "core/fetch/Body.h"
-#include "core/fetch/FetchRequestData.h"
 #include "core/fetch/Headers.h"
+#include "modules/ModulesExport.h"
+#include "modules/fetch/FetchRequestData.h"
 #include "platform/bindings/ScriptWrappable.h"
 #include "platform/heap/Handle.h"
 #include "platform/weborigin/KURL.h"
@@ -25,7 +25,7 @@
 
 using RequestInfo = RequestOrUSVString;
 
-class CORE_EXPORT Request final : public Body {
+class MODULES_EXPORT Request final : public Body {
   DEFINE_WRAPPERTYPEINFO();
   WTF_MAKE_NONCOPYABLE(Request);
 
diff --git a/third_party/WebKit/Source/core/fetch/Request.idl b/third_party/WebKit/Source/modules/fetch/Request.idl
similarity index 100%
rename from third_party/WebKit/Source/core/fetch/Request.idl
rename to third_party/WebKit/Source/modules/fetch/Request.idl
diff --git a/third_party/WebKit/Source/core/fetch/RequestInit.cpp b/third_party/WebKit/Source/modules/fetch/RequestInit.cpp
similarity index 99%
rename from third_party/WebKit/Source/core/fetch/RequestInit.cpp
rename to third_party/WebKit/Source/modules/fetch/RequestInit.cpp
index 5d8907927..5a80160 100644
--- a/third_party/WebKit/Source/core/fetch/RequestInit.cpp
+++ b/third_party/WebKit/Source/modules/fetch/RequestInit.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/RequestInit.h"
+#include "modules/fetch/RequestInit.h"
 
 #include "bindings/core/v8/Dictionary.h"
 #include "bindings/core/v8/ExceptionState.h"
diff --git a/third_party/WebKit/Source/core/fetch/RequestInit.h b/third_party/WebKit/Source/modules/fetch/RequestInit.h
similarity index 100%
rename from third_party/WebKit/Source/core/fetch/RequestInit.h
rename to third_party/WebKit/Source/modules/fetch/RequestInit.h
diff --git a/third_party/WebKit/Source/core/fetch/RequestTest.cpp b/third_party/WebKit/Source/modules/fetch/RequestTest.cpp
similarity index 98%
rename from third_party/WebKit/Source/core/fetch/RequestTest.cpp
rename to third_party/WebKit/Source/modules/fetch/RequestTest.cpp
index 0f38c285..0a7dd95d 100644
--- a/third_party/WebKit/Source/core/fetch/RequestTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/RequestTest.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/Request.h"
+#include "modules/fetch/Request.h"
 
 #include <memory>
 #include "bindings/core/v8/ExceptionState.h"
@@ -75,10 +75,9 @@
   web_request.SetCacheMode(kCacheMode);
   web_request.SetRedirectMode(kRedirectMode);
   web_request.SetRequestContext(kContext);
-  for (int i = 0; headers[i].key; ++i) {
+  for (int i = 0; headers[i].key; ++i)
     web_request.SetHeader(WebString::FromUTF8(headers[i].key),
                           WebString::FromUTF8(headers[i].value));
-  }
   web_request.SetReferrer(referrer, kReferrerPolicy);
 
   Request* request = Request::Create(scope.GetScriptState(), web_request);
diff --git a/third_party/WebKit/Source/core/fetch/Response.cpp b/third_party/WebKit/Source/modules/fetch/Response.cpp
similarity index 99%
rename from third_party/WebKit/Source/core/fetch/Response.cpp
rename to third_party/WebKit/Source/modules/fetch/Response.cpp
index 71bb2141..76f2d44c 100644
--- a/third_party/WebKit/Source/core/fetch/Response.cpp
+++ b/third_party/WebKit/Source/modules/fetch/Response.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/Response.h"
+#include "modules/fetch/Response.h"
 
 #include <memory>
 #include "base/memory/scoped_refptr.h"
@@ -18,7 +18,6 @@
 #include "core/fetch/BlobBytesConsumer.h"
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/FormDataBytesConsumer.h"
-#include "core/fetch/ResponseInit.h"
 #include "core/fileapi/Blob.h"
 #include "core/frame/UseCounter.h"
 #include "core/html/forms/FormData.h"
@@ -26,6 +25,7 @@
 #include "core/typed_arrays/DOMArrayBuffer.h"
 #include "core/typed_arrays/DOMArrayBufferView.h"
 #include "core/url/URLSearchParams.h"
+#include "modules/fetch/ResponseInit.h"
 #include "platform/bindings/ScriptState.h"
 #include "platform/bindings/V8PrivateProperty.h"
 #include "platform/loader/fetch/FetchUtils.h"
diff --git a/third_party/WebKit/Source/core/fetch/Response.h b/third_party/WebKit/Source/modules/fetch/Response.h
similarity index 96%
rename from third_party/WebKit/Source/core/fetch/Response.h
rename to third_party/WebKit/Source/modules/fetch/Response.h
index ad1eb93..56dc7096 100644
--- a/third_party/WebKit/Source/core/fetch/Response.h
+++ b/third_party/WebKit/Source/modules/fetch/Response.h
@@ -7,11 +7,11 @@
 
 #include "bindings/core/v8/Dictionary.h"
 #include "bindings/core/v8/ScriptValue.h"
-#include "core/CoreExport.h"
 #include "core/fetch/Body.h"
 #include "core/fetch/BodyStreamBuffer.h"
-#include "core/fetch/FetchResponseData.h"
 #include "core/fetch/Headers.h"
+#include "modules/ModulesExport.h"
+#include "modules/fetch/FetchResponseData.h"
 #include "platform/bindings/ScriptWrappable.h"
 #include "platform/blob/BlobData.h"
 #include "platform/heap/Handle.h"
@@ -25,7 +25,7 @@
 class ScriptState;
 class WebServiceWorkerResponse;
 
-class CORE_EXPORT Response final : public Body {
+class MODULES_EXPORT Response final : public Body {
   DEFINE_WRAPPERTYPEINFO();
   WTF_MAKE_NONCOPYABLE(Response);
 
diff --git a/third_party/WebKit/Source/core/fetch/Response.idl b/third_party/WebKit/Source/modules/fetch/Response.idl
similarity index 100%
rename from third_party/WebKit/Source/core/fetch/Response.idl
rename to third_party/WebKit/Source/modules/fetch/Response.idl
diff --git a/third_party/WebKit/Source/core/fetch/ResponseInit.idl b/third_party/WebKit/Source/modules/fetch/ResponseInit.idl
similarity index 100%
rename from third_party/WebKit/Source/core/fetch/ResponseInit.idl
rename to third_party/WebKit/Source/modules/fetch/ResponseInit.idl
diff --git a/third_party/WebKit/Source/core/fetch/ResponseTest.cpp b/third_party/WebKit/Source/modules/fetch/ResponseTest.cpp
similarity index 98%
rename from third_party/WebKit/Source/core/fetch/ResponseTest.cpp
rename to third_party/WebKit/Source/modules/fetch/ResponseTest.cpp
index 61a7f59..4905804a 100644
--- a/third_party/WebKit/Source/core/fetch/ResponseTest.cpp
+++ b/third_party/WebKit/Source/modules/fetch/ResponseTest.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fetch/Response.h"
+#include "modules/fetch/Response.h"
 
 #include <memory>
 #include "bindings/core/v8/ExceptionState.h"
@@ -12,9 +12,9 @@
 #include "core/fetch/BytesConsumer.h"
 #include "core/fetch/BytesConsumerTestUtil.h"
 #include "core/fetch/DataConsumerHandleTestUtil.h"
-#include "core/fetch/FetchResponseData.h"
 #include "core/frame/Frame.h"
 #include "core/testing/DummyPageHolder.h"
+#include "modules/fetch/FetchResponseData.h"
 #include "platform/bindings/ScriptState.h"
 #include "platform/blob/BlobData.h"
 #include "platform/testing/UnitTestHelpers.h"
@@ -45,10 +45,9 @@
   web_response->SetStatus(kStatus);
   web_response->SetStatusText(status_text);
   web_response->SetResponseType(network::mojom::FetchResponseType::kDefault);
-  for (int i = 0; headers[i].key; ++i) {
+  for (int i = 0; headers[i].key; ++i)
     web_response->SetHeader(WebString::FromUTF8(headers[i].key),
                             WebString::FromUTF8(headers[i].value));
-  }
   return web_response;
 }
 
diff --git a/third_party/WebKit/Source/modules/fetch/testing/InternalsFetch.cpp b/third_party/WebKit/Source/modules/fetch/testing/InternalsFetch.cpp
index 5f7b733..3a42336 100644
--- a/third_party/WebKit/Source/modules/fetch/testing/InternalsFetch.cpp
+++ b/third_party/WebKit/Source/modules/fetch/testing/InternalsFetch.cpp
@@ -4,7 +4,7 @@
 
 #include "modules/fetch/testing/InternalsFetch.h"
 
-#include "core/fetch/Response.h"
+#include "modules/fetch/Response.h"
 #include "platform/wtf/Vector.h"
 
 namespace blink {
diff --git a/third_party/WebKit/Source/modules/fetch/testing/WorkerInternalsFetch.cpp b/third_party/WebKit/Source/modules/fetch/testing/WorkerInternalsFetch.cpp
index 40705e29..86e1134 100644
--- a/third_party/WebKit/Source/modules/fetch/testing/WorkerInternalsFetch.cpp
+++ b/third_party/WebKit/Source/modules/fetch/testing/WorkerInternalsFetch.cpp
@@ -4,7 +4,7 @@
 
 #include "modules/fetch/testing/WorkerInternalsFetch.h"
 
-#include "core/fetch/Response.h"
+#include "modules/fetch/Response.h"
 #include "platform/wtf/Vector.h"
 
 namespace blink {
diff --git a/third_party/WebKit/Source/modules/modules_idl_files.gni b/third_party/WebKit/Source/modules/modules_idl_files.gni
index ecca7b5..b21459e 100644
--- a/third_party/WebKit/Source/modules/modules_idl_files.gni
+++ b/third_party/WebKit/Source/modules/modules_idl_files.gni
@@ -116,6 +116,8 @@
           "encryptedmedia/MediaKeySystemAccess.idl",
           "encryptedmedia/MediaKeys.idl",
           "eventsource/EventSource.idl",
+          "fetch/Request.idl",
+          "fetch/Response.idl",
           "filesystem/DOMFileSystem.idl",
           "filesystem/DOMFileSystemSync.idl",
           "filesystem/DirectoryEntry.idl",
@@ -482,6 +484,7 @@
                     "encryptedmedia/MediaKeySystemConfiguration.idl",
                     "encryptedmedia/MediaKeySystemMediaCapability.idl",
                     "eventsource/EventSourceInit.idl",
+                    "fetch/ResponseInit.idl",
                     "filesystem/FileSystemFlags.idl",
                     "gamepad/GamepadEffectParameters.idl",
                     "gamepad/GamepadEventInit.idl",
diff --git a/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp b/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
index fd0cc5f..2057f6df 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
@@ -8,10 +8,10 @@
 #include "bindings/core/v8/ToV8ForCore.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BytesConsumerForDataConsumerHandle.h"
-#include "core/fetch/Request.h"
-#include "core/fetch/Response.h"
 #include "core/frame/UseCounter.h"
 #include "core/timing/WorkerGlobalScopePerformance.h"
+#include "modules/fetch/Request.h"
+#include "modules/fetch/Response.h"
 #include "modules/serviceworkers/FetchRespondWithObserver.h"
 #include "modules/serviceworkers/ServiceWorkerError.h"
 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
diff --git a/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h b/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h
index cd1328e..b852bd0 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h
+++ b/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h
@@ -11,9 +11,9 @@
 #include "bindings/core/v8/ScriptPromise.h"
 #include "bindings/core/v8/ScriptPromiseProperty.h"
 #include "core/dom/ContextLifecycleObserver.h"
-#include "core/fetch/Request.h"
 #include "modules/EventModules.h"
 #include "modules/ModulesExport.h"
+#include "modules/fetch/Request.h"
 #include "modules/serviceworkers/ExtendableEvent.h"
 #include "modules/serviceworkers/FetchEventInit.h"
 #include "modules/serviceworkers/WaitUntilObserver.h"
diff --git a/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp b/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp
index 6d5a0f6..b9554454 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/FetchRespondWithObserver.cpp
@@ -10,7 +10,7 @@
 #include <v8.h>
 #include "bindings/core/v8/ScriptValue.h"
 #include "bindings/core/v8/V8BindingForCore.h"
-#include "bindings/core/v8/V8Response.h"
+#include "bindings/modules/v8/V8Response.h"
 #include "core/dom/ExecutionContext.h"
 #include "core/fetch/BodyStreamBuffer.h"
 #include "core/fetch/BytesConsumer.h"
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h
index bb00358..89709cb2 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h
@@ -31,7 +31,7 @@
 #define ServiceWorkerGlobalScope_h
 
 #include <memory>
-#include "bindings/core/v8/request_or_usv_string.h"
+#include "bindings/modules/v8/request_or_usv_string.h"
 #include "core/workers/WorkerGlobalScope.h"
 #include "modules/ModulesExport.h"
 #include "platform/heap/Handle.h"
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.cpp
index b4deda6a..94f8444f 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScopeClient.cpp
@@ -33,8 +33,8 @@
 #include <memory>
 #include <utility>
 #include "core/dom/ExecutionContext.h"
-#include "core/fetch/Response.h"
 #include "core/workers/WorkerGlobalScope.h"
+#include "modules/fetch/Response.h"
 #include "public/platform/WebURL.h"
 #include "public/platform/modules/payments/WebPaymentHandlerResponse.h"
 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h"