forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
weblayer: adds Profile.destroyAndDeleteDataFromDiskSoon
This method immediately marks the profile for deletion, and calls destroyAndDeleteDataFromDisk() when safe. Safe means no more browsers reference the profile. I kept most of the logic for this in the Java side, as I don't think the C++ side needs this. BUG=1142989 TEST=testDestroyAndDeleteDataFromDiskSoonWhenInUse and DestroyFromOnBrowserRemoved Change-Id: Ic5322022ab49a515d6e0319159ff79c91249db7a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519836 Commit-Queue: Scott Violet <sky@chromium.org> Reviewed-by: Bo <boliu@chromium.org> Cr-Commit-Position: refs/heads/master@{#824238}
- Loading branch information
Scott Violet
authored and
Commit Bot
committed
Nov 5, 2020
1 parent
d593e5c
commit 6acf9a2
Showing
18 changed files
with
420 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2020 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. | ||
|
||
#include "weblayer/browser/browser_list_proxy.h" | ||
|
||
#include "base/android/jni_android.h" | ||
#include "weblayer/browser/browser_impl.h" | ||
#include "weblayer/browser/browser_list.h" | ||
#include "weblayer/browser/java/jni/BrowserList_jni.h" | ||
|
||
namespace weblayer { | ||
|
||
BrowserListProxy::BrowserListProxy() | ||
: java_browser_list_(Java_BrowserList_createBrowserList( | ||
base::android::AttachCurrentThread())) {} | ||
|
||
BrowserListProxy::~BrowserListProxy() = default; | ||
|
||
void BrowserListProxy::OnBrowserCreated(Browser* browser) { | ||
Java_BrowserList_onBrowserCreated( | ||
base::android::AttachCurrentThread(), java_browser_list_, | ||
static_cast<BrowserImpl*>(browser)->java_browser()); | ||
} | ||
|
||
void BrowserListProxy::OnBrowserDestroyed(Browser* browser) { | ||
Java_BrowserList_onBrowserDestroyed( | ||
base::android::AttachCurrentThread(), java_browser_list_, | ||
static_cast<BrowserImpl*>(browser)->java_browser()); | ||
} | ||
|
||
static void JNI_BrowserList_CreateBrowserList(JNIEnv* env) { | ||
BrowserList::GetInstance(); | ||
} | ||
|
||
} // namespace weblayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2020 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 WEBLAYER_BROWSER_BROWSER_LIST_PROXY_H_ | ||
#define WEBLAYER_BROWSER_BROWSER_LIST_PROXY_H_ | ||
|
||
#include <jni.h> | ||
|
||
#include "base/android/scoped_java_ref.h" | ||
#include "weblayer/browser/browser_list_observer.h" | ||
|
||
namespace weblayer { | ||
|
||
// Owns the Java BrowserList implementation and funnels all BrowserListObserver | ||
// calls to the java side. | ||
class BrowserListProxy : public BrowserListObserver { | ||
public: | ||
BrowserListProxy(); | ||
BrowserListProxy(const BrowserListProxy&) = delete; | ||
BrowserListProxy& operator=(const BrowserListProxy&) = delete; | ||
~BrowserListProxy() override; | ||
|
||
// BrowserListObserver: | ||
void OnBrowserCreated(Browser* browser) override; | ||
void OnBrowserDestroyed(Browser* browser) override; | ||
|
||
private: | ||
base::android::ScopedJavaGlobalRef<jobject> java_browser_list_; | ||
}; | ||
|
||
} // namespace weblayer | ||
|
||
#endif // WEBLAYER_BROWSER_BROWSER_LIST_PROXY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
weblayer/browser/java/org/chromium/weblayer_private/BrowserList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2020 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. | ||
|
||
package org.chromium.weblayer_private; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.chromium.base.ObserverList; | ||
import org.chromium.base.annotations.CalledByNative; | ||
import org.chromium.base.annotations.JNINamespace; | ||
import org.chromium.base.annotations.NativeMethods; | ||
|
||
/** | ||
* Tracks the set of Browsers. | ||
*/ | ||
@JNINamespace("weblayer") | ||
public final class BrowserList { | ||
private static BrowserList sInstance; | ||
private final ObserverList<BrowserListObserver> mObservers; | ||
|
||
@CalledByNative | ||
private static BrowserList createBrowserList() { | ||
// The native side should call this only once. | ||
assert sInstance == null; | ||
sInstance = new BrowserList(); | ||
return sInstance; | ||
} | ||
|
||
@NonNull | ||
public static BrowserList getInstance() { | ||
// The native side creates this early on. It should never be null. | ||
if (sInstance == null) { | ||
BrowserListJni.get().createBrowserList(); | ||
assert sInstance != null; | ||
} | ||
return sInstance; | ||
} | ||
|
||
private BrowserList() { | ||
mObservers = new ObserverList<>(); | ||
} | ||
|
||
public void addObserver(BrowserListObserver o) { | ||
mObservers.addObserver(o); | ||
} | ||
|
||
public void removeObserver(BrowserListObserver o) { | ||
mObservers.removeObserver(o); | ||
} | ||
|
||
@CalledByNative | ||
private void onBrowserCreated(BrowserImpl browser) { | ||
for (BrowserListObserver observer : mObservers) { | ||
observer.onBrowserCreated(browser); | ||
} | ||
} | ||
|
||
@CalledByNative | ||
private void onBrowserDestroyed(BrowserImpl browser) { | ||
for (BrowserListObserver observer : mObservers) { | ||
observer.onBrowserDestroyed(browser); | ||
} | ||
} | ||
|
||
@NativeMethods | ||
interface Natives { | ||
void createBrowserList(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
weblayer/browser/java/org/chromium/weblayer_private/BrowserListObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2020 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. | ||
|
||
package org.chromium.weblayer_private; | ||
|
||
/** | ||
* Notified of changes to BrowserList. | ||
*/ | ||
public interface BrowserListObserver { | ||
void onBrowserCreated(BrowserImpl browser); | ||
void onBrowserDestroyed(BrowserImpl browser); | ||
} |
Oops, something went wrong.