Commit d3285ea5 authored by michaeln@google.com's avatar michaeln@google.com

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
parent d949ae90
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/file_path.h" #include "base/file_path.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/supports_user_data.h"
#include "base/time.h" #include "base/time.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
...@@ -32,7 +33,16 @@ class NET_EXPORT_PRIVATE ChunkCallback { ...@@ -32,7 +33,16 @@ class NET_EXPORT_PRIVATE ChunkCallback {
virtual ~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: public:
enum Type { enum Type {
TYPE_BYTES, TYPE_BYTES,
...@@ -231,7 +241,7 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> { ...@@ -231,7 +241,7 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> {
friend class base::RefCounted<UploadData>; friend class base::RefCounted<UploadData>;
~UploadData(); virtual ~UploadData();
std::vector<Element> elements_; std::vector<Element> elements_;
int64 identifier_; int64 identifier_;
......
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -198,6 +198,11 @@ void BlobStorageController::ResolveBlobReferencesInUploadData( ...@@ -198,6 +198,11 @@ void BlobStorageController::ResolveBlobReferencesInUploadData(
if (blob_data->items().empty()) if (blob_data->items().empty())
continue; 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. // Insert the elements in the referred blob data.
// Note that we traverse from the bottom so that the elements can be // Note that we traverse from the bottom so that the elements can be
// inserted in the original order. // inserted in the original order.
...@@ -208,13 +213,13 @@ void BlobStorageController::ResolveBlobReferencesInUploadData( ...@@ -208,13 +213,13 @@ void BlobStorageController::ResolveBlobReferencesInUploadData(
switch (item.type) { switch (item.type) {
case BlobData::TYPE_DATA: case BlobData::TYPE_DATA:
// TODO(jianli): Figure out how to avoid copying the 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( iter->SetToBytes(
&item.data.at(0) + static_cast<int>(item.offset), &item.data.at(0) + static_cast<int>(item.offset),
static_cast<int>(item.length)); static_cast<int>(item.length));
break; break;
case BlobData::TYPE_FILE: case BlobData::TYPE_FILE:
// TODO(michaeln): Ensure that any temp files survive till the
// net::URLRequest is done with the upload.
iter->SetToFilePathRange( iter->SetToFilePathRange(
item.file_path, item.file_path,
item.offset, item.offset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment