2011-04-05 18:17:33 +02:00
|
|
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
2010-10-15 20:37:25 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef BROWSER_FILE_WRITER_H_
|
|
|
|
#define BROWSER_FILE_WRITER_H_
|
|
|
|
|
2011-04-05 18:17:33 +02:00
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
#include "base/memory/weak_ptr.h"
|
2010-10-15 20:37:25 +02:00
|
|
|
#include "webkit/fileapi/webfilewriter_base.h"
|
|
|
|
|
2011-01-07 22:34:20 +01:00
|
|
|
namespace net {
|
2010-10-15 20:37:25 +02:00
|
|
|
class URLRequestContext;
|
2011-04-05 18:17:33 +02:00
|
|
|
} // namespace net
|
|
|
|
|
|
|
|
namespace fileapi {
|
|
|
|
class FileSystemContext;
|
2011-01-07 22:34:20 +01:00
|
|
|
}
|
2010-10-15 20:37:25 +02:00
|
|
|
|
|
|
|
// An implementation of WebFileWriter for use in test_shell and DRT.
|
|
|
|
class BrowserFileWriter : public fileapi::WebFileWriterBase,
|
2011-05-16 18:56:12 +02:00
|
|
|
public base::SupportsWeakPtr<BrowserFileWriter> {
|
2010-10-15 20:37:25 +02:00
|
|
|
public:
|
|
|
|
BrowserFileWriter(
|
2011-05-16 18:56:12 +02:00
|
|
|
const GURL& path,
|
2011-04-05 18:17:33 +02:00
|
|
|
WebKit::WebFileWriterClient* client,
|
|
|
|
fileapi::FileSystemContext* file_system_context);
|
2010-10-15 20:37:25 +02:00
|
|
|
virtual ~BrowserFileWriter();
|
|
|
|
|
2011-04-05 18:17:33 +02:00
|
|
|
// Called by CefProcessIOThread when the context is created and destroyed.
|
2011-01-07 22:34:20 +01:00
|
|
|
static void InitializeOnIOThread(net::URLRequestContext* request_context) {
|
2010-10-15 20:37:25 +02:00
|
|
|
request_context_ = request_context;
|
|
|
|
}
|
|
|
|
static void CleanupOnIOThread() {
|
|
|
|
request_context_ = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// WebFileWriterBase overrides
|
2011-05-16 18:56:12 +02:00
|
|
|
virtual void DoTruncate(const GURL& path, int64 offset);
|
|
|
|
virtual void DoWrite(const GURL& path, const GURL& blob_url,
|
2010-10-15 20:37:25 +02:00
|
|
|
int64 offset);
|
|
|
|
virtual void DoCancel();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class IOThreadProxy;
|
|
|
|
scoped_refptr<IOThreadProxy> io_thread_proxy_;
|
2011-01-07 22:34:20 +01:00
|
|
|
static net::URLRequestContext* request_context_;
|
2010-10-15 20:37:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BROWSER_FILE_WRITER_H_
|