#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/services/media_gallery_util/public/cpp/local_media_data_source_factory.h"
#include <vector>
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/receiver.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/content_uri_utils.h"
#endif
namespace {
MediaDataCallback;
ReadFileCallback;
void OnReadComplete(scoped_refptr<base::SequencedTaskRunner> main_task_runner,
ReadFileCallback cb,
bool success,
std::vector<char> data) { … }
void ReadFile(const base::FilePath& file_path,
int64_t position,
int64_t length,
scoped_refptr<base::SequencedTaskRunner> main_task_runner,
ReadFileCallback cb) { … }
class LocalMediaDataSource : public chrome::mojom::MediaDataSource { … };
}
LocalMediaDataSourceFactory::LocalMediaDataSourceFactory(
const base::FilePath& file_path,
scoped_refptr<base::SequencedTaskRunner> file_task_runner)
: … { … }
LocalMediaDataSourceFactory::~LocalMediaDataSourceFactory() = default;
std::unique_ptr<chrome::mojom::MediaDataSource>
LocalMediaDataSourceFactory::CreateMediaDataSource(
mojo::PendingReceiver<chrome::mojom::MediaDataSource> receiver,
MediaDataCallback media_data_callback) { … }