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

Unified Diff: content/child/blob_storage/blob_transport_controller.h

Issue 1414123002: [BlobAsync] Renderer support for blob file writing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-hookup
Patch Set: linker fix Created 4 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: content/child/blob_storage/blob_transport_controller.h
diff --git a/content/child/blob_storage/blob_transport_controller.h b/content/child/blob_storage/blob_transport_controller.h
index c9c62ce55ba69e36a4b5bcd6f7ddcc52c421057e..4d86513e599a23f16c1acb991cdeeba15747d014 100644
--- a/content/child/blob_storage/blob_transport_controller.h
+++ b/content/child/blob_storage/blob_transport_controller.h
@@ -10,12 +10,15 @@
#include <map>
#include <memory>
#include <string>
+#include <utility>
#include <vector>
+#include "base/callback_forward.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/shared_memory_handle.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "ipc/ipc_platform_file.h"
#include "storage/common/blob_storage/blob_storage_constants.h"
@@ -24,6 +27,7 @@ namespace base {
template <typename T>
struct DefaultLazyInstanceTraits;
class SingleThreadTaskRunner;
+class TaskRunner;
}
namespace storage {
@@ -33,6 +37,7 @@ struct BlobItemBytesResponse;
}
namespace IPC {
+class Message;
class Sender;
}
@@ -63,17 +68,20 @@ class CONTENT_EXPORT BlobTransportController {
static void InitiateBlobTransfer(
const std::string& uuid,
const std::string& content_type,
- std::unique_ptr<BlobConsolidation> consolidation,
+ scoped_refptr<BlobConsolidation> consolidation,
scoped_refptr<ThreadSafeSender> sender,
base::SingleThreadTaskRunner* io_runner,
scoped_refptr<base::SingleThreadTaskRunner> main_runner);
- // This responds to the request using the sender.
+ // This responds to the request using the |sender|. If we need to save files
+ // then we we hold onto the sender to send the (possibly multiple) reponses
+ // asynchronously. Use CancelAllBlobTransfers to stop usage of the |sender|.
void OnMemoryRequest(
const std::string& uuid,
const std::vector<storage::BlobItemBytesRequest>& requests,
std::vector<base::SharedMemoryHandle>* memory_handles,
const std::vector<IPC::PlatformFileForTransit>& file_handles,
+ base::TaskRunner* file_runner,
IPC::Sender* sender);
void OnCancel(const std::string& uuid,
@@ -85,13 +93,32 @@ class CONTENT_EXPORT BlobTransportController {
return blob_storage_.find(uuid) != blob_storage_.end();
}
+ // Invalidates all asynchronously running memory request handlers and clears
+ // the internal state. If our map wasn't previously empty, then we call
+ // ChildProcess::ReleaseProcess to release our previous reference.
+ void CancelAllBlobTransfers();
+
private:
+ friend struct base::DefaultLazyInstanceTraits<BlobTransportController>;
friend class BlobTransportControllerTest;
FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, Descriptions);
FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, Responses);
FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, SharedMemory);
+ FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, Disk);
FRIEND_TEST_ALL_PREFIXES(BlobTransportControllerTest, ResponsesErrors);
+ using ResponseCallback = base::Callback<void(
+ const std::vector<storage::BlobItemBytesResponse>& /* responses */)>;
+ using CancelCallback =
+ base::Callback<void(storage::IPCBlobCreationCancelCode /* reason */)>;
michaeln 2016/04/26 22:50:08 these callback tyhpes are no longer needed since t
dmurph 2016/04/27 19:14:04 Done.
+
+ enum class ResponsesStatus {
+ BLOB_NOT_FOUND,
+ SHARED_MEMORY_MAP_FAILED,
+ PENDING_IO,
+ SUCCESS
+ };
+
static void GetDescriptions(BlobConsolidation* consolidation,
size_t max_data_population,
std::vector<storage::DataElement>* out);
@@ -99,36 +126,25 @@ class CONTENT_EXPORT BlobTransportController {
BlobTransportController();
~BlobTransportController();
- // Clears all internal state. If our map wasn't previously empty, then we call
- // ChildProcess::ReleaseProcess to release our previous reference.
- void ClearForTesting();
-
- enum class ResponsesStatus {
- BLOB_NOT_FOUND,
- SHARED_MEMORY_MAP_FAILED,
- SUCCESS
- };
- friend struct base::DefaultLazyInstanceTraits<BlobTransportController>;
+ void OnFileWriteComplete(
+ IPC::Sender* sender,
+ const std::string& uuid,
+ const std::pair<std::vector<storage::BlobItemBytesResponse>,
+ storage::IPCBlobCreationCancelCode>& result);
void StoreBlobDataForRequests(
const std::string& uuid,
- std::unique_ptr<BlobConsolidation> consolidation,
+ scoped_refptr<BlobConsolidation> consolidation,
scoped_refptr<base::SingleThreadTaskRunner> main_runner);
- ResponsesStatus GetResponses(
- const std::string& uuid,
- const std::vector<storage::BlobItemBytesRequest>& requests,
- std::vector<base::SharedMemoryHandle>* memory_handles,
- const std::vector<IPC::PlatformFileForTransit>& file_handles,
- std::vector<storage::BlobItemBytesResponse>* output);
-
// Deletes the consolidation, and if we removed the last consolidation from
// our map, we call ChildProcess::ReleaseProcess to release our previous
// reference.
void ReleaseBlobConsolidation(const std::string& uuid);
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_;
- std::map<std::string, std::unique_ptr<BlobConsolidation>> blob_storage_;
+ std::map<std::string, scoped_refptr<BlobConsolidation>> blob_storage_;
+ base::WeakPtrFactory<BlobTransportController> ptr_factory_;
michaeln 2016/04/26 22:50:08 nit: this is typically named something like weak_f
dmurph 2016/04/27 19:14:04 done.
DISALLOW_COPY_AND_ASSIGN(BlobTransportController);
};

Powered by Google App Engine
This is Rietveld 408576698