blob: c1f12abbf12eb1a0b65a4b728c51501a85824e8d [file] [log] [blame]
Benjamin Lermanc440c742015-09-28 13:52:53 +02001// Copyright 2015 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 SHELL_ANDROID_URL_RESPONSE_DISK_CACHE_DELEGATE_IMPL_H_
6#define SHELL_ANDROID_URL_RESPONSE_DISK_CACHE_DELEGATE_IMPL_H_
7
8#include <map>
9
10#include "base/android/scoped_java_ref.h"
11#include "services/url_response_disk_cache/url_response_disk_cache_delegate.h"
12#include "shell/context.h"
13
14struct AAssetManager;
15
16namespace shell {
17
18class URLResponseDiskCacheDelegateImpl
19 : public mojo::URLResponseDiskCacheDelegate {
20 public:
21 URLResponseDiskCacheDelegateImpl(Context* contest, jobject j_asset_manager);
22 ~URLResponseDiskCacheDelegateImpl() override;
23
24 private:
25 // mojo:URLResponseDiskCacheDelegate implementation:
26 void GetInitialPath(scoped_refptr<base::TaskRunner> task_runner,
27 const std::string& url,
28 const base::FilePath& target,
29 const base::Callback<void(bool)>& callback) override;
30
31 bool ExtractAsset(const std::string& asset_name,
32 const base::FilePath& target);
33
34 void PopulateAssetsIfNeeded();
35
36 Context* context_;
37 base::android::ScopedJavaGlobalRef<jobject> j_asset_manager_;
38 std::map<std::string, std::string> url_to_asset_name_;
39 AAssetManager* asset_manager_;
40
41 DISALLOW_COPY_AND_ASSIGN(URLResponseDiskCacheDelegateImpl);
42};
43
44} // namespace shell
45
46#endif // SHELL_ANDROID_URL_RESPONSE_DISK_CACHE_DELEGATE_IMPL_H_