Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ba7a3adde17a11ab85ce7b4fab6efb3679a1cad3 |
| --- /dev/null |
| +++ b/content/child/blob_storage/blob_transport_controller.h |
| @@ -0,0 +1,75 @@ |
| +// Copyright 2015 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. |
| + |
| +#ifndef CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |
| +#define CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/shared_memory_handle.h" |
| +#include "content/child/blob_storage/blob_transport_temporary_holder.h" |
| +#include "storage/common/blob_storage/blob_storage_constants.h" |
| + |
| +template <typename T> |
| +struct DefaultSingletonTraits; |
| + |
| +namespace IPC { |
| +class Sender; |
| +} |
| + |
| +namespace content { |
| + |
| +// Must be used on the IO thread. |
| +class BlobTransportController { |
| + public: |
| + static BlobTransportController* GetInstance(); |
| + |
| + // This kicks off a blob transfer to the browser thread, which involves |
| + // sending an IPC message and storing the blob consolidation object. |
| + void InitiateBlobTransfer(const std::string& uuid, |
| + const std::string& type, |
| + scoped_ptr<BlobConsolidation> consolidation, |
| + IPC::Sender* sender); |
| + |
| + // This responds to the request using 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, |
| + IPC::Sender* sender); |
| + |
| + void OnCancel(const std::string& uuid, |
| + storage::IPCBlobCreationCancelCode code); |
| + |
| + void OnDone(const std::string& uuid); |
| + |
| + // This tells the controller that the channel has been closed, and that all |
| + // senders previously given to the controller are now invalid. |
| + void OnChannelClose(); |
|
michaeln
2015/08/18 02:50:35
Shutdown() might be a better name. When this happe
dmurph
2015/10/07 00:32:36
I actually don't need this anymore. We just use th
|
| + |
| + ~BlobTransportController(); |
| + |
| + private: |
| + friend struct DefaultSingletonTraits<BlobTransportController>; |
| + |
| + BlobTransportController(); |
| + |
| + // Sends the IPC to cancel the blob transfer, and releases the blob from |
| + // internal storage. |
| + void CancelBlobTransfer(const std::string& uuid, |
| + storage::IPCBlobCreationCancelCode code, |
| + IPC::Sender* sender); |
| + |
| + BlobTransportTemporaryHolder holder_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BlobTransportController); |
| +}; |
| + |
| +} // namespace content |
| +#endif // CONTENT_CHILD_BLOB_STORAGE_BLOB_TRANSPORT_CONTROLLER_H_ |