summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_dir_url_request_job.h
blob: e9f566fbb01fc0f5273d511f1499b453cc1f13bf (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
51
52
53
54
55
56
57
58
59
60
61
62
// 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_DIR_URL_REQUEST_JOB_H_
#define WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_
#pragma once

#include <string>
#include <vector>

#include "base/file_path.h"
#include "base/file_util_proxy.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/message_loop_proxy.h"
#include "base/platform_file.h"
#include "base/task.h"
#include "net/url_request/url_request_job.h"
#include "webkit/fileapi/file_system_url_request_job_base.h"

namespace fileapi {
class FileSystemContext;
class FileSystemOperation;

// A request job that handles reading filesystem: URLs for directories.
class FileSystemDirURLRequestJob : public FileSystemURLRequestJobBase {
 public:
  FileSystemDirURLRequestJob(
      net::URLRequest* request, FileSystemContext* file_system_context,
      scoped_refptr<base::MessageLoopProxy> file_thread_proxy);

  // URLRequestJob methods:
  virtual void Start();
  virtual void Kill();
  virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read);
  virtual bool GetCharset(std::string* charset);

  // FilterContext methods (via URLRequestJob):
  virtual bool GetMimeType(std::string* mime_type) const;
  // TODO(adamk): Implement GetResponseInfo and GetResponseCode to simulate
  // an HTTP response.

 protected:
  // FileSystemURLRequestJobBase methods.
  virtual void DidGetLocalPath(const FilePath& local_path);

  virtual ~FileSystemDirURLRequestJob();

  void DidReadDirectory(base::PlatformFileError error_code,
                        const std::vector<base::FileUtilProxy::Entry>& entries);
  fileapi::FileSystemOperation* GetNewOperation();

  std::string data_;
  ScopedRunnableMethodFactory<FileSystemDirURLRequestJob> method_factory_;
  base::ScopedCallbackFactory<FileSystemDirURLRequestJob> callback_factory_;

  DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob);
};

}  // namespace fileapi

#endif  // WEBKIT_FILEAPI_FILE_SYSTEM_DIR_URL_REQUEST_JOB_H_