Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: ios/chrome/browser/ui/external_file_remover.h

Issue 2588713002: Upstream Chrome on iOS source code [4/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 IOS_CHROME_BROWSER_UI_EXTERNAL_FILE_REMOVER_H_
6 #define IOS_CHROME_BROWSER_UI_EXTERNAL_FILE_REMOVER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h"
11 #include "components/sessions/core/tab_restore_service_observer.h"
12
13 @class BrowserViewController;
14 namespace sessions {
15 class TabRestoreService;
16 }
17
18 // ExternalFileRemover is responsible for removing documents received from other
19 // applications that are not in the list of recently closed tabs, open tabs or
20 // bookmarks.
21 class ExternalFileRemover : public sessions::TabRestoreServiceObserver {
22 public:
23 // Creates an ExternalFileRemover to remove external documents not referenced
24 // by the specified BrowserViewController. Use Remove to initiate the removal.
25 explicit ExternalFileRemover(BrowserViewController* bvc);
26 ~ExternalFileRemover() override;
27
28 // sessions::TabRestoreServiceObserver methods
29 void TabRestoreServiceChanged(sessions::TabRestoreService* service) override;
30 void TabRestoreServiceDestroyed(
31 sessions::TabRestoreService* service) override;
32
33 // Post a delayed task to clean up the files received from other applications.
34 // |callback| is called when the clean up has finished.
35 void RemoveAfterDelay(const base::TimeDelta& delay,
36 const base::Closure& callback);
37
38 private:
39 // Removes files received from other apps. If |all_files| is true, then
40 // all files including files that may be referenced by tabs through restore
41 // service or history. Otherwise, only the unreferenced files are removed.
42 // |callback| is called when the removal finishes.
43 void RemoveFiles(bool all_files, const base::Closure& callback);
44 // Pointer to the tab restore service in the browser state associated with
45 // |bvc_|.
46 sessions::TabRestoreService* tabRestoreService_;
47 // BrowserViewController used to get the referenced files. Must outlive this
48 // object.
49 BrowserViewController* bvc_;
50 // Used to ensure |Remove()| is not run when this object is destroyed.
51 base::WeakPtrFactory<ExternalFileRemover> weak_ptr_factory_;
52 // Loads the |tabRestoreService_| if necessary. Removes all files received
53 // from other apps if |all_files| is true. Otherwise, removes the unreferenced
54 // files only. |callback| is called when the removal finishes.
55 void Remove(bool all_files, const base::Closure& callback);
56 };
57
58 #endif // IOS_CHROME_BROWSER_UI_EXTERNAL_FILE_REMOVER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/external_file_controller.mm ('k') | ios/chrome/browser/ui/external_file_remover.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698