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

Side by Side Diff: content/browser/appcache/appcache_navigation_handle.h

Issue 2501343003: PlzNavigate: AppCache support. (Closed)
Patch Set: Rebase to tip correctly 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 2016 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 CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11
12 namespace content {
13
14 class AppCacheNavigationHandleCore;
15 class ChromeAppCacheService;
16
17 // This class is used to manage the lifetime of AppCacheHosts created during
18 // navigation. This is a UI thread class, with a pendant class on the IO
19 // thread, the AppCacheNavigationHandleCore.
20 //
21 // The lifetime of the AppCacheNavigationHandle, the
22 // AppCacheNavigationHandleCore and the AppCacheHost are the following :
23 // 1) We create a AppCacheNavigationHandle on the UI thread with a
24 // app cache host id of -1. This also leads to the creation of a
25 // AppCacheNavigationHandleCore with an id of -1. Every time
26 // an AppCacheNavigationHandle instance is created the global host id is
27 // decremented by 1.
28 //
29 // 2) When the navigation request is sent to the IO thread, we include a
30 // pointer to the AppCacheNavigationHandleCore.
31 //
32 // 3. The AppCacheHost instance is created and its ownership is passed to the
33 // AppCacheNavigationHandleCore instance. Now the app cache host id is
34 // updated.
35 //
36 // 4) The AppCacheNavigationHandleCore instance informs the
37 // AppCacheNavigationHandle instance on the UI thread that the app cache
38 // host id was updated.
39 //
40 // 5) When the navigation is ready to commit, the NavigationRequest will
41 // update the RequestNavigationParams based on the id from the
42 // AppCacheNavigationHandle.
43 //
44 // 6. The commit leads to AppCache registrations happening from the renderer.
45 // This is via the IPC message AppCacheHostMsg_RegisterHost. The
46 // AppCacheDispatcherHost class which handles these IPCs will be informed
47 // about these hosts when the navigation commits. It will ignore the
48 // host registrations as they have already been registered. The
49 // ownership of the AppCacheHost is passed from the
50 // AppCacheNavigationHandle core to the AppCacheBackend.
51
52 // 7) When the navigation finishes, the AppCacheNavigationHandle is
53 // destroyed. The destructor of the AppCacheNavigationHandle posts a
54 // task to destroy the AppacheNavigationHandleCore on the IO thread.
55
56 class AppCacheNavigationHandle {
57 public:
58 AppCacheNavigationHandle(ChromeAppCacheService* appcache_service);
59 ~AppCacheNavigationHandle();
60
61 int appcache_host_id() const { return appcache_host_id_; }
62 AppCacheNavigationHandleCore* core() const { return core_; }
63
64 // Called when a navigation is committed. The |process_id| parameter is
65 // is the process id of the renderer.
66 void CommitNavigation(int process_id);
67
68 private:
69 int appcache_host_id_;
70 AppCacheNavigationHandleCore* core_;
michaeln 2016/12/03 00:58:58 i'd vote to use a std::unique_ptr<> here to expres
ananta 2016/12/03 14:55:04 Done.
71 base::WeakPtrFactory<AppCacheNavigationHandle> weak_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(AppCacheNavigationHandle);
74 };
75
76 } // namespace content
77
78 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_NAVIGATION_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698