Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / file_reader.h
blob109a97a8b47f2f07454f6a15d2207297b8dbd905
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_FILE_READER_H_
6 #define EXTENSIONS_BROWSER_FILE_READER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "extensions/common/extension_resource.h"
14 namespace base {
15 class MessageLoop;
18 // This file defines an interface for reading a file asynchronously on a
19 // background thread.
20 // Consider abstracting out a FilePathProvider (ExtensionResource) and moving
21 // back to chrome/browser/net if other subsystems want to use it.
22 class FileReader : public base::RefCountedThreadSafe<FileReader> {
23 public:
24 // Reports success or failure and the data of the file upon success.
25 typedef base::Callback<void(bool, const std::string&)> Callback;
27 FileReader(const extensions::ExtensionResource& resource,
28 const Callback& callback);
30 // Called to start reading the file on a background thread. Upon completion,
31 // the callback will be notified of the results.
32 void Start();
34 private:
35 friend class base::RefCountedThreadSafe<FileReader>;
37 virtual ~FileReader();
39 void ReadFileOnBackgroundThread();
41 extensions::ExtensionResource resource_;
42 Callback callback_;
43 base::MessageLoop* origin_loop_;
46 #endif // EXTENSIONS_BROWSER_FILE_READER_H_