Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / translate / content / renderer / data_file_renderer_cld_data_provider.h
1 // Copyright 2014 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.
4
5 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_
6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_
7
8 #include "base/files/file.h"
9 #include "base/macros.h"
10 #include "components/translate/content/renderer/renderer_cld_data_provider.h"
11 #include "ipc/ipc_platform_file.h"
12
13 namespace translate {
14
15 class DataFileRendererCldDataProvider : public RendererCldDataProvider {
16  public:
17   explicit DataFileRendererCldDataProvider(content::RenderViewObserver*);
18   virtual ~DataFileRendererCldDataProvider();
19   // RendererCldDataProvider implementations:
20   virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE;
21   virtual void SendCldDataRequest() OVERRIDE;
22   virtual void SetCldAvailableCallback(base::Callback<void(void)>) OVERRIDE;
23   virtual bool IsCldDataAvailable() OVERRIDE;
24
25  private:
26   void OnCldDataAvailable(const IPC::PlatformFileForTransit ipc_file_handle,
27                           const uint64 data_offset,
28                           const uint64 data_length);
29   void LoadCldData(base::File file,
30                    const uint64 data_offset,
31                    const uint64 data_length);
32   content::RenderViewObserver* render_view_observer_;
33   base::Callback<void(void)> cld_available_callback_;
34
35   DISALLOW_COPY_AND_ASSIGN(DataFileRendererCldDataProvider);
36 };
37
38 }  // namespace translate
39
40 #endif  // COMPONENTS_TRANSLATE_CONTENT_RENDERER_DATA_FILE_RENDERER_CLD_DATA_PROVIDER_H_