summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_url_request_job_base.h
blob: 10549fe7dd2adc941b9816346004c15de023ec60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2011 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 WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_BASE_H_
#define WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_BASE_H_
#pragma once

#include "base/file_path.h"
#include "base/message_loop_proxy.h"
#include "net/url_request/url_request_job.h"
#include "webkit/fileapi/file_system_callback_dispatcher.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation.h"

namespace fileapi {

// A base class for request jobs that handle reading filesystem: URLs for
// files and directories.
class FileSystemURLRequestJobBase : public net::URLRequestJob {
 public:
  FileSystemURLRequestJobBase(
      net::URLRequest* request, FileSystemContext* file_system_context,
      scoped_refptr<base::MessageLoopProxy> file_thread_proxy);

  virtual ~FileSystemURLRequestJobBase();

  void StartAsync();

 protected:
  virtual void DidGetLocalPath(const FilePath& local_path) = 0 ;

  void NotifyFailed(int rv);
  void RespondFailedOnIOThread(int error_code);
  FileSystemOperation* GetNewOperation();

  FilePath relative_file_path_;
  FilePath absolute_file_path_;
  scoped_refptr<FileSystemContext> file_system_context_;
  scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;

 private:
  friend class LocalPathCallbackDispatcher;
  void OnGetLocalPath(const FilePath& local_path);
  DISALLOW_COPY_AND_ASSIGN(FileSystemURLRequestJobBase);
};

}  // namespace fileapi

#endif  // WEBKIT_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_BASE_H_