firebase::storage::Controller

#include <controller.h>

Controls an ongoing operation, allowing the caller to Pause, Resume or Cancel an ongoing download or upload.

Summary

An instance of Controller can be constructed and passed to StorageReference::GetBytes(), StorageReference::GetFile(), StorageReference::PutBytes(), or StorageReference::PutFile() to become associated with it. Each Controller can only be associated with one operation at a time.

A Controller is also passed as an argument to Listener's callbacks. The Controller passed to a StorageReference operation is not the same object passed to Listener callbacks (though it refers to the same operation), so there are no restrictions on the lifetime of the Controller the user creates (but the Controller passed into a Listener callbacks should only be used from within that callback).

This class is currently not thread safe and can only be called on the main thread.

Constructors and Destructors

Controller()
Default constructor.
Controller(const Controller & other)
Copy constructor.
Controller(Controller && other)
Move constructor.
~Controller()
Destructor.

Public functions

Cancel()
bool
Cancels the operation currently in progress.
GetReference() const
Returns the StorageReference associated with this Controller.
Pause()
bool
Pauses the operation currently in progress.
Resume()
bool
Resumes the operation that is paused.
bytes_transferred() const
int64_t
Returns the number of bytes transferred so far.
is_paused() const
bool
Returns true if the operation is paused.
is_valid() const
bool
Returns true if this Controller is valid, false if it is not valid.
operator=(const Controller & other)
Copy assignment operator.
operator=(Controller && other)
Move assignment operator.
total_byte_count() const
int64_t
Returns the total bytes to be transferred.

Public functions

Cancel

bool Cancel()

Cancels the operation currently in progress.

Details
Returns
True if the operation was successfully canceled, false otherwise.

Controller

 Controller()

Default constructor.

You may construct your own Controller to pass into various StorageReference operations.

Controller

 Controller(
  const Controller & other
)

Copy constructor.

Details
Parameters
other
Controller to copy from.

Controller

 Controller(
  Controller && other
)

Move constructor.

Moving is an efficient operation for Controller instances.

Details
Parameters
other
Controller to move from.

GetReference

StorageReference GetReference() const 

Returns the StorageReference associated with this Controller.

Details
Returns
The StorageReference associated with this Controller.

Pause

bool Pause()

Pauses the operation currently in progress.

Details
Returns
True if the operation was successfully paused, false otherwise.

Resume

bool Resume()

Resumes the operation that is paused.

Details
Returns
True if the operation was successfully resumed, false otherwise.

bytes_transferred

int64_t bytes_transferred() const 

Returns the number of bytes transferred so far.

Details
Returns
The number of bytes transferred so far.

is_paused

bool is_paused() const 

Returns true if the operation is paused.

is_valid

bool is_valid() const 

Returns true if this Controller is valid, false if it is not valid.

An invalid Controller is one that is not associated with an operation.

Details
Returns
true if this Controller is valid, false if this Controller is invalid.

operator=

Controller & operator=(
  const Controller & other
)

Copy assignment operator.

Details
Parameters
other
Controller to copy from.
Returns
Reference to the destination Controller.

operator=

Controller & operator=(
  Controller && other
)

Move assignment operator.

Moving is an efficient operation for Controller instances.

Details
Parameters
other
Controller to move from.
Returns
Reference to the destination Controller.

total_byte_count

int64_t total_byte_count() const 

Returns the total bytes to be transferred.

Details
Returns
The total bytes to be transferred. This will return -1 if the size of the transfer is unknown.

~Controller

 ~Controller()

Destructor.