summaryrefslogtreecommitdiffstats
path: root/ios/web/browsing_data_partition_impl.h
blob: 21b2ee452b049670a1c8c431258a8c18d5034f8e (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
// Copyright 2015 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 IOS_WEB_BROWSING_DATA_PARTITION_IMPL_H_
#define IOS_WEB_BROWSING_DATA_PARTITION_IMPL_H_

#import "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "base/supports_user_data.h"
#include "ios/web/active_state_manager_impl.h"
#include "ios/web/public/browsing_data_partition.h"

@class CRWBrowsingDataStore;

namespace web {

class ActiveStateManagerImpl;
class BrowserState;

// Concrete subclass of web::BrowsingDataPartition. Observes
// ActiveStateManagerImpl::Observer methods to trigger stash/restore operations
// on the underlying CRWBrowsingDataStore.
class BrowsingDataPartitionImpl : public BrowsingDataPartition,
                                  public base::SupportsUserData::Data,
                                  public web::ActiveStateManagerImpl::Observer {
 public:
  explicit BrowsingDataPartitionImpl(BrowserState* browser_state);
  ~BrowsingDataPartitionImpl() override;

  // BrowsingDataPartition implementation.
  CRWBrowsingDataStore* GetBrowsingDataStore() override;

  // ActiveStateManagerImpl::Observer implementation.
  void OnActive() override;
  void OnInactive() override;
  void WillBeDestroyed() override;

 private:
  BrowserState* browser_state_;  // weak, owns this object.
  // The browsing data store backing this object.
  base::scoped_nsobject<CRWBrowsingDataStore> browsing_data_store_;
  // Weak pointer to the associated active state manager.
  ActiveStateManagerImpl* active_state_manager_;

  DISALLOW_COPY_AND_ASSIGN(BrowsingDataPartitionImpl);
};

}  // namespace web

#endif  // IOS_WEB_BROWSING_DATA_PARTITION_IMPL_H_