chromium/net/test/url_request/url_request_test_job_backed_by_file.cc

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

// For loading files, we make use of overlapped i/o to ensure that reading from
// the filesystem (e.g., a network filesystem) does not block the calling
// thread.  An alternative approach would be to use a background thread or pool
// of threads, but it seems better to leverage the operating system's ability
// to do background file reads for us.
//
// Since overlapped reads require a 'static' buffer for the duration of the
// asynchronous read, the URLRequestTestJobBackedByFile keeps a buffer as a
// member var.  In URLRequestTestJobBackedByFile::Read, data is simply copied
// from the object's buffer into the given buffer.  If there is no data to copy,
// the URLRequestTestJobBackedByFile attempts to read more from the file to fill
// its buffer.  If reading from the file does not complete synchronously, then
// the URLRequestTestJobBackedByFile waits for a signal from the OS that the
// overlapped read has completed.  It does so by leveraging the
// MessageLoop::WatchObject API.

#include "net/test/url_request/url_request_test_job_backed_by_file.h"

#include "base/compiler_specific.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
#include "base/task/task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "net/base/file_stream.h"
#include "net/base/filename_util.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
#include "net/filter/gzip_source_stream.h"
#include "net/filter/source_stream.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request_error_job.h"
#include "url/gurl.h"

#if BUILDFLAG(IS_WIN)
#include "base/win/shortcut.h"
#endif

namespace net {

URLRequestTestJobBackedByFile::FileMetaInfo::FileMetaInfo() = default;

URLRequestTestJobBackedByFile::URLRequestTestJobBackedByFile(
    URLRequest* request,
    const base::FilePath& file_path,
    const scoped_refptr<base::TaskRunner>& file_task_runner)
    :{}

void URLRequestTestJobBackedByFile::Start() {}

void URLRequestTestJobBackedByFile::Kill() {}

int URLRequestTestJobBackedByFile::ReadRawData(IOBuffer* dest, int dest_size) {}

bool URLRequestTestJobBackedByFile::GetMimeType(std::string* mime_type) const {}

void URLRequestTestJobBackedByFile::SetExtraRequestHeaders(
    const HttpRequestHeaders& headers) {}

void URLRequestTestJobBackedByFile::GetResponseInfo(HttpResponseInfo* info) {}

void URLRequestTestJobBackedByFile::OnOpenComplete(int result) {}

void URLRequestTestJobBackedByFile::OnSeekComplete(int64_t result) {}

void URLRequestTestJobBackedByFile::OnReadComplete(IOBuffer* buf, int result) {}

URLRequestTestJobBackedByFile::~URLRequestTestJobBackedByFile() = default;

std::unique_ptr<SourceStream>
URLRequestTestJobBackedByFile::SetUpSourceStream() {}

std::unique_ptr<URLRequestTestJobBackedByFile::FileMetaInfo>
URLRequestTestJobBackedByFile::FetchMetaInfo(const base::FilePath& file_path) {}

void URLRequestTestJobBackedByFile::DidFetchMetaInfo(
    std::unique_ptr<FileMetaInfo> meta_info) {}

void URLRequestTestJobBackedByFile::DidOpen(int result) {}

void URLRequestTestJobBackedByFile::DidSeek(int64_t result) {}

void URLRequestTestJobBackedByFile::DidRead(scoped_refptr<IOBuffer> buf,
                                            int result) {}

}  // namespace net