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

Side by Side Diff: build/android/incremental_install/java/org/chromium/incrementalinstall/LockFile.java

Issue 1385893004: GN incremental_install: Enable lib copying for all devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 2 months 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
« no previous file with comments | « build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.incrementalinstall; 5 package org.chromium.incrementalinstall;
6 6
7 import android.util.Log; 7 import android.util.Log;
8 8
9 import java.io.File; 9 import java.io.File;
10 import java.io.FileOutputStream; 10 import java.io.FileOutputStream;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 try { 92 try {
93 FileOutputStream outputStream = new FileOutputStream(file); 93 FileOutputStream outputStream = new FileOutputStream(file);
94 FileLock lock = outputStream.getChannel().tryLock(); 94 FileLock lock = outputStream.getChannel().tryLock();
95 if (lock != null) { 95 if (lock != null) {
96 Log.i(TAG, "Created lock file: " + file); 96 Log.i(TAG, "Created lock file: " + file);
97 return new LockFile(file, outputStream, lock); 97 return new LockFile(file, outputStream, lock);
98 } 98 }
99 outputStream.close(); 99 outputStream.close();
100 } catch (IOException e) { 100 } catch (IOException e) {
101 // Do nothing. We didn't get the lock. 101 // Do nothing. We didn't get the lock.
102 Log.w(TAG, "Exception trying to acquire lock " + file, e);
102 } 103 }
103 return null; 104 return null;
104 } 105 }
105 106
106 /** 107 /**
107 * Waits for the given file to not exist. 108 * Waits for the given file to not exist.
108 */ 109 */
109 static void waitForRuntimeLock(final File file, long timeoutMs) { 110 static void waitForRuntimeLock(final File file, long timeoutMs) {
110 pollingWait(new Callable<Boolean>() { 111 pollingWait(new Callable<Boolean>() {
111 @Override public Boolean call() { 112 @Override public Boolean call() {
112 return !file.exists(); 113 return !file.exists();
113 } 114 }
114 }, file, timeoutMs); 115 }, file, timeoutMs);
115 } 116 }
116 117
117 /** 118 /**
118 * Releases and deletes the lock file. 119 * Releases and deletes the lock file.
119 */ 120 */
120 void release() throws IOException { 121 void release() throws IOException {
121 Log.i(TAG, "Deleting lock file: " + mFile); 122 Log.i(TAG, "Deleting lock file: " + mFile);
122 mFileLock.release(); 123 mFileLock.release();
123 mOutputStream.close(); 124 mOutputStream.close();
124 if (!mFile.delete()) { 125 if (!mFile.delete()) {
125 throw new IOException("Failed to delete lock file: " + mFile); 126 throw new IOException("Failed to delete lock file: " + mFile);
126 } 127 }
127 } 128 }
128 } 129 }
OLDNEW
« no previous file with comments | « build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698