Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1061)

Unified Diff: Source/core/platform/network/chromium/ResourceHandle.cpp

Issue 14246006: Implementing timeout support for XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@timeoutResourceHandle
Patch Set: Adressing eview comments. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/network/chromium/ResourceHandle.cpp
diff --git a/Source/core/platform/network/chromium/ResourceHandle.cpp b/Source/core/platform/network/chromium/ResourceHandle.cpp
index 54175ef216086b78905b6a56f4874d017cb3f4f1..53c9ddff8540c30ec1bce47ae9fb3328607d9908 100644
--- a/Source/core/platform/network/chromium/ResourceHandle.cpp
+++ b/Source/core/platform/network/chromium/ResourceHandle.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -58,6 +59,7 @@ ResourceHandleInternal::ResourceHandleInternal(NetworkingContext* context, const
, m_owner(0)
, m_client(client)
, m_state(ConnectionStateNew)
+ , m_timeoutTimer(this, &ResourceHandleInternal::timerFired)
{
}
@@ -73,6 +75,9 @@ void ResourceHandleInternal::start()
WrappedResourceRequest wrappedRequest(m_request);
wrappedRequest.setAllowStoredCredentials(allowStoredCredentials());
m_loader->loadAsynchronously(wrappedRequest, this);
+
+ if (m_request.timeoutInterval() > 0)
+ m_timeoutTimer.startOneShot(m_request.timeoutInterval());
}
void ResourceHandleInternal::cancel()
@@ -177,6 +182,19 @@ ResourceHandleInternal* ResourceHandleInternal::FromResourceHandle(ResourceHandl
return handle->d.get();
}
+void ResourceHandleInternal::timerFired(Timer<ResourceHandleInternal>* timer)
+{
+ ASSERT_UNUSED(timer, timer == &m_timeoutTimer);
+
+ m_state = ConnectionStateCanceled;
+ m_loader->cancel();
+ if (m_client) {
+ ResourceError error;
+ error.setIsTimeout(true);
+ m_client->didFail(m_owner, error);
+ }
abarth-chromium 2013/04/19 16:29:48 I'm still concerned that this function copy/pastes
+ }
+
// ResourceHandle -------------------------------------------------------------
ResourceHandle::ResourceHandle(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)

Powered by Google App Engine
This is Rietveld 408576698