• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PathUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.chromium.base.PathUtils的典型用法代码示例。如果您正苦于以下问题:Java PathUtils类的具体用法?Java PathUtils怎么用?Java PathUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PathUtils类属于org.chromium.base包,在下文中一共展示了PathUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testNetLogAfterShutdown

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testNetLogAfterShutdown() throws Exception {
    mTestFramework = startCronetTestFramework();
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(
            mUrl, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    mTestFramework.mCronetEngine.shutdown();

    File directory = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("cronet", "json", directory);
    try {
        mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
        fail("Should throw an exception.");
    } catch (Exception e) {
        assertEquals("Engine is shut down.", e.getMessage());
    }
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:CronetUrlRequestContextTest.java


示例2: testNetLogStartMultipleTimes

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
public void testNetLogStartMultipleTimes() throws Exception {
    mTestFramework = startCronetTestFramework();
    File directory = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("cronet", "json", directory);
    // Start NetLog multiple times.
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(
            mUrl, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    mTestFramework.mCronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:CronetUrlRequestContextTest.java


示例3: testNetLogStopMultipleTimes

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
public void testNetLogStopMultipleTimes() throws Exception {
    mTestFramework = startCronetTestFramework();
    File directory = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("cronet", "json", directory);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(
            mUrl, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    // Stop NetLog multiple times.
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:26,代码来源:CronetUrlRequestContextTest.java


示例4: testNetLogWithBytes

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testNetLogWithBytes() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    CronetEngine cronetEngine = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    // Start NetLog with logAll as true.
    cronetEngine.startNetLogToFile(file.getPath(), true);
    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder =
            new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), cronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    cronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertTrue(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:CronetUrlRequestContextTest.java


示例5: install

import org.chromium.base.PathUtils; //导入依赖的package包/类
/**
 * Installs test files that are included in {@code path}.
 * @params context Application context
 * @params path
 */
private static void install(Context context, String path) throws IOException {
    AssetManager assetManager = context.getAssets();
    String files[] = assetManager.list(path);
    Log.i(TAG, "Loading " + path + " ...");
    String root = PathUtils.getDataDirectory(context);
    if (files.length == 0) {
        // The path is a file, so copy the file now.
        copyTestFile(context, path, root + "/" + path);
    } else {
        // The path is a directory, so recursively handle its files, since
        // the directory can contain subdirectories.
        String fullPath = root + "/" + path;
        File dir = new File(fullPath);
        if (!dir.exists()) {
            Log.i(TAG, "Creating directory " + fullPath + " ...");
            if (!dir.mkdir()) {
                throw new IOException("Directory not created.");
            }
        }
        for (int i = 0; i < files.length; i++) {
            install(context, path + "/" + files[i]);
        }
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:30,代码来源:TestFilesInstaller.java


示例6: preInflationStartup

import org.chromium.base.PathUtils; //导入依赖的package包/类
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    ChromeWebApkHost.init();

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:ChromeBrowserInitializer.java


示例7: cleanupPersistentData

import org.chromium.base.PathUtils; //导入依赖的package包/类
/**
 * Remove on-disk thumbnails that are no longer needed.
 * @param modelSelector The selector that answers whether a tab is currently present.
 */
public void cleanupPersistentData(TabModelSelector modelSelector) {
    if (mNativeTabContentManager == 0) return;
    File[] files = PathUtils.getThumbnailCacheDirectory(mContext).listFiles();
    if (files == null) return;

    for (File file : files) {
        try {
            int id = Integer.parseInt(file.getName());
            if (TabModelUtils.getTabById(modelSelector.getModel(false), id) == null
                    && TabModelUtils.getTabById(modelSelector.getModel(true), id) == null) {
                nativeRemoveTabThumbnail(mNativeTabContentManager, id);
            }
        } catch (NumberFormatException expected) {
            // This is an unknown file name, we'll leave it there.
        }
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:22,代码来源:TabContentManager.java


示例8: testNetLog

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No netlogs for pure java impl
public void testNetLog() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    CronetEngine cronetEngine = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    // Start NetLog immediately after the request context is created to make
    // sure that the call won't crash the app even when the native request
    // context is not fully initialized. See crbug.com/470196.
    cronetEngine.startNetLogToFile(file.getPath(), false);

    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder =
            new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), cronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    cronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:CronetUrlRequestContextTest.java


示例9: testNoStopNetLog

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No netlogs for pure java impl
// Tests that if stopNetLog is not explicity called, CronetEngine.shutdown()
// will take care of it. crbug.com/623701.
public void testNoStopNetLog() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    CronetEngine cronetEngine = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    cronetEngine.startNetLogToFile(file.getPath(), false);

    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder =
            new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), cronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    // Shut down the engine without calling stopNetLog.
    cronetEngine.shutdown();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:CronetUrlRequestContextTest.java


示例10: testNetLog

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No NetLog from HttpURLConnection
public void testNetLog() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
            context,
            new UrlRequestContextConfig().setLibraryName("cronet_tests"));
    // Start NetLog immediately after the request context is created to make
    // sure that the call won't crash the app even when the native request
    // context is not fully initialized. See crbug.com/470196.
    factory.startNetLogToFile(file.getPath(), false);
    // Starts a request.
    HashMap<String, String> headers = new HashMap<String, String>();
    TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
    HttpUrlRequest request = factory.createRequest(
            mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener);
    request.start();
    listener.blockForComplete();
    factory.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:CronetUrlTest.java


示例11: testSetSSLKeyLogFile

import org.chromium.base.PathUtils; //导入依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testSetSSLKeyLogFile() throws Exception {
    String url = Http2TestServer.getEchoMethodUrl();
    File dir = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("ssl_key_log_file", "", dir);

    JSONObject experimentalOptions = new JSONObject().put("ssl_key_log_file", file.getPath());
    mBuilder.setExperimentalOptions(experimentalOptions.toString());
    mTestFramework = new CronetTestFramework(null, null, getContext(), mBuilder);

    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder builder = new UrlRequest.Builder(
            url, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    UrlRequest urlRequest = builder.build();
    urlRequest.start();
    callback.blockForDone();
    assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
    assertEquals("GET", callback.mResponseAsString);

    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    BufferedReader logReader = new BufferedReader(new FileReader(file));
    boolean validFile = false;
    try {
        String logLine;
        while ((logLine = logReader.readLine()) != null) {
            if (logLine.contains("CLIENT_RANDOM")) {
                validFile = true;
                break;
            }
        }
    } finally {
        logReader.close();
    }
    assertTrue(validFile);
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:41,代码来源:ExperimentalOptionsTest.java


示例12: onCreate

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this);
    mConfig = getIntent().getData();
    // Execute benchmarks on another thread to avoid networking on main thread.
    new BenchmarkTask().execute();
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:9,代码来源:CronetPerfTestActivity.java


示例13: doInBackground

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
    if (mDestroyed) return null;

    mTabFileNames = getOrCreateStateDirectory().list();
    String thumbnailDirectory = PathUtils.getThumbnailCacheDirectory();
    mThumbnailFileNames = new File(thumbnailDirectory).list();

    mOtherTabIds = new SparseBooleanArray();
    getTabsFromOtherStateFiles(mOtherTabIds);
    return null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:TabbedModeTabPersistencePolicy.java


示例14: shouldRequestFileAccess

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public boolean shouldRequestFileAccess(String url, Tab tab) {
    // If the tab is null, then do not attempt to prompt for access.
    if (tab == null) return false;

    // If the url points inside of Chromium's data directory, no permissions are necessary.
    // This is required to prevent permission prompt when uses wants to access offline pages.
    if (url.startsWith("file://" + PathUtils.getDataDirectory())) {
        return false;
    }

    return !tab.getWindowAndroid().hasPermission(permission.WRITE_EXTERNAL_STORAGE)
            && tab.getWindowAndroid().canRequestPermission(permission.WRITE_EXTERNAL_STORAGE);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:ExternalNavigationDelegateImpl.java


示例15: initializeLibraryDependencies

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
protected void initializeLibraryDependencies() {
    // The ResourceExtractor is only needed by the browser process, but this will have no
    // impact on the renderer process construction.
    ResourceBundle.initializeLocalePaks(this, R.array.locale_paks);
    if (!BuildInfo.hasLanguageApkSplits(this)) {
        ResourceExtractor.setResourcesToExtract(ResourceBundle.getActiveLocaleResources());
    }
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:11,代码来源:ChromeApplication.java


示例16: shouldRequestFileAccess

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public boolean shouldRequestFileAccess(String url, Tab tab) {
    // If the tab is null, then do not attempt to prompt for access.
    if (tab == null) return false;

    // If the url points inside of Chromium's data directory, no permissions are necessary.
    // This is required to prevent permission prompt when uses wants to access offline pages.
    if (url.startsWith(UrlConstants.FILE_URL_PREFIX + PathUtils.getDataDirectory())) {
        return false;
    }

    return !tab.getWindowAndroid().hasPermission(permission.READ_EXTERNAL_STORAGE)
            && tab.getWindowAndroid().canRequestPermission(permission.READ_EXTERNAL_STORAGE);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:ExternalNavigationDelegateImpl.java


示例17: onCreate

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public void onCreate() {
    // We want to do this at the earliest possible point in startup.
    UmaUtils.recordMainEntryPointTime();
    super.onCreate();

    ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);

    mObservers = new ArrayList<ChromiumTestShellApplicationObserver>();
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:13,代码来源:ChromiumTestShellApplication.java


示例18: loadLibrary

import org.chromium.base.PathUtils; //导入依赖的package包/类
/**
 * Loads the native library, and performs basic static construction of objects needed
 * to run webview in this process. Does not create threads; safe to call from zygote.
 * Note: it is up to the caller to ensure this is only called once.
 */
public static void loadLibrary() {
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    try {
        LibraryLoader.loadNow(null);
    } catch (ProcessInitException e) {
        throw new RuntimeException("Cannot load WebView", e);
    }
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:14,代码来源:AwBrowserProcess.java


示例19: onCreate

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    /* Copying the www folder to the data folder at the start of the application */
    String dataDirectoryPath = PathUtils.getDataDirectory(this);
    File f = new File(dataDirectoryPath);
    try {
        AssetManager assetManager = getAssets();
        InputStream is = assetManager.open("www.zip");
        if (!f.exists()) {
            f.mkdirs();
        }
        File targetFile = new File(f.getAbsolutePath() + "/" + "www.zip");
        OutputStream io = new FileOutputStream(targetFile);
        copyFile(is, io);

        unzipFile(targetFile.getAbsolutePath(), f.getAbsolutePath() + "/");

    } catch (IOException e) {
        e.printStackTrace();
    }

    String startupUrl = Uri.fromFile(new File(f.getAbsolutePath() + "/www/index.html")).toString();
    this.setStartupUrl(startupUrl);

    super.onCreate(savedInstanceState);


    /**
     * This line when used crashes the app with Exception
     * java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
     * cannot be cast to android.widget.FrameLayout$LayoutParams
     * I have no idea why this happens until now
     */
    //this.loadUrl("http://google.com");

}
 
开发者ID:R4md4c,项目名称:cordova-android-chromium,代码行数:37,代码来源:MainActivity.java


示例20: loadLibrary

import org.chromium.base.PathUtils; //导入依赖的package包/类
/**
 * Loads the native library, and performs basic static construction of objects needed
 * to run webview in this process. Does not create threads; safe to call from zygote.
 * Note: it is up to the caller to ensure this is only called once.
 */
public static void loadLibrary() {
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    try {
        LibraryLoader.loadNow();
    } catch (ProcessInitException e) {
        throw new RuntimeException("Cannot load WebView", e);
    }
}
 
开发者ID:R4md4c,项目名称:cordova-android-chromium,代码行数:14,代码来源:AwBrowserProcess.java



注:本文中的org.chromium.base.PathUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OWLObjectIntersectionOf类代码示例发布时间:2022-05-21
下一篇:
Java CompositeFilter类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap