summaryrefslogtreecommitdiffstats
path: root/content/browser/android/system_ui_resource_manager_impl.h
blob: 54b2bd39d957f4c40ae88b2240214f5df1e7145e (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
// Copyright 2014 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 CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_IMPL_H_
#define CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_IMPL_H_

#include "base/basictypes.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "ui/base/android/system_ui_resource_manager.h"

class SkBitmap;

namespace cc {
class UIResourceBitmap;
}

namespace content {

class UIResourceProvider;

class CONTENT_EXPORT SystemUIResourceManagerImpl
    : public ui::SystemUIResourceManager {
 public:
  explicit SystemUIResourceManagerImpl(
      UIResourceProvider* ui_resource_provider);
  virtual ~SystemUIResourceManagerImpl();

  virtual void PreloadResource(ResourceType type) override;
  virtual cc::UIResourceId GetUIResourceId(ResourceType type) override;

 private:
  friend class TestSystemUIResourceManagerImpl;
  class Entry;

  // Start loading the resource bitmap.  virtual for testing.
  virtual void BuildResource(ResourceType type);

  Entry* GetEntry(ResourceType type);
  void OnFinishedLoadBitmap(ResourceType, SkBitmap* bitmap_holder);

  scoped_ptr<Entry> resource_map_[RESOURCE_TYPE_LAST + 1];
  UIResourceProvider* ui_resource_provider_;

  base::WeakPtrFactory<SystemUIResourceManagerImpl> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(SystemUIResourceManagerImpl);
};

}  // namespace content

#endif  // CONTENT_BROWSER_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_IMPL_H_