summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 03:10:19 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-02 03:10:19 +0000
commitd3285ea56af238916e228cf03625625980c1608f (patch)
treedb9a0b5c2b12a4977ecb67995bcd1c5bf49e52d8
parentd949ae90ff1fd791db9fb3e699188c17789973ae (diff)
downloadchromium_src-d3285ea56af238916e228cf03625625980c1608f.zip
chromium_src-d3285ea56af238916e228cf03625625980c1608f.tar.gz
chromium_src-d3285ea56af238916e228cf03625625980c1608f.tar.bz2
Ensure blobs and associated temp/shareable files survive URLRequest uploads.
BUG=115603 Review URL: https://chromiumcodereview.appspot.com/9569035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124581 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/base/upload_data.h14
-rw-r--r--webkit/blob/blob_storage_controller.cc11
2 files changed, 20 insertions, 5 deletions
diff --git a/net/base/upload_data.h b/net/base/upload_data.h
index a7f3d34..c3ccf83 100644
--- a/net/base/upload_data.h
+++ b/net/base/upload_data.h
@@ -13,6 +13,7 @@
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
+#include "base/supports_user_data.h"
#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_export.h"
@@ -32,7 +33,16 @@ class NET_EXPORT_PRIVATE ChunkCallback {
virtual ~ChunkCallback() {}
};
-class NET_EXPORT UploadData : public base::RefCounted<UploadData> {
+//-----------------------------------------------------------------------------
+// A very concrete class representing the data to be uploaded as part of a
+// URLRequest.
+//
+// Until there is a more abstract class for this, this one derives from
+// SupportsUserData to allow users to stash random data by
+// key and ensure it's destruction when UploadData is finally deleted.
+class NET_EXPORT UploadData
+ : public base::RefCounted<UploadData>,
+ public base::SupportsUserData {
public:
enum Type {
TYPE_BYTES,
@@ -231,7 +241,7 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> {
friend class base::RefCounted<UploadData>;
- ~UploadData();
+ virtual ~UploadData();
std::vector<Element> elements_;
int64 identifier_;
diff --git a/webkit/blob/blob_storage_controller.cc b/webkit/blob/blob_storage_controller.cc
index e3bcc6f..ed617e6 100644
--- a/webkit/blob/blob_storage_controller.cc
+++ b/webkit/blob/blob_storage_controller.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -198,6 +198,11 @@ void BlobStorageController::ResolveBlobReferencesInUploadData(
if (blob_data->items().empty())
continue;
+ // Ensure the blob and any attached shareable files survive until
+ // upload completion.
+ upload_data->SetUserData(blob_data,
+ new base::UserDataAdapter<BlobData>(blob_data));
+
// Insert the elements in the referred blob data.
// Note that we traverse from the bottom so that the elements can be
// inserted in the original order.
@@ -208,13 +213,13 @@ void BlobStorageController::ResolveBlobReferencesInUploadData(
switch (item.type) {
case BlobData::TYPE_DATA:
// TODO(jianli): Figure out how to avoid copying the data.
+ // TODO(michaeln): Now that blob_data surives for the duration,
+ // maybe UploadData could take a raw ptr without having to copy.
iter->SetToBytes(
&item.data.at(0) + static_cast<int>(item.offset),
static_cast<int>(item.length));
break;
case BlobData::TYPE_FILE:
- // TODO(michaeln): Ensure that any temp files survive till the
- // net::URLRequest is done with the upload.
iter->SetToFilePathRange(
item.file_path,
item.offset,