chromium/chrome/services/media_gallery_util/public/cpp/local_media_data_source_factory.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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  // BUILDFLAG(IS_ANDROID)

namespace {

MediaDataCallback;
ReadFileCallback;

// Helper method to post |cb| on the |main_task_runner| with read result.
void OnReadComplete(scoped_refptr<base::SequencedTaskRunner> main_task_runner,
                    ReadFileCallback cb,
                    bool success,
                    std::vector<char> data) {}

// Reads a chunk of the file on a file thread, and reply the data or error to
// main thread.
void ReadFile(const base::FilePath& file_path,
              int64_t position,
              int64_t length,
              scoped_refptr<base::SequencedTaskRunner> main_task_runner,
              ReadFileCallback cb) {}

// Read media file incrementally and send data to the utility process to parse
// media metadata. Must live and die on main thread and does blocking IO on
// |file_task_runner_|.
class LocalMediaDataSource : public chrome::mojom::MediaDataSource {};

}  // namespace

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) {}